\brief پیش ذخیره را انجام می‌دهد

@param $create boolean
ساخت یا به روز رسانی را تعیین می‌کند
549230
function preSave($create = false)
    {
        if ($this->id == '') {
            $this->creation_dtime = gmdate('Y-m-d H:i:s');
        }
        $this->modif_dtime = gmdate('Y-m-d H:i:s');
    }
1000365
public function create()
    {
        // Validate form
        $form = $this->getForm('Create' . $this->getEntityName());
        if (!$form->isValid()) {
            return false;
        }

        // Insert new entity
        $now    = new \DateTime();
        $entity = $form->getData();
        $entity->setLastModified($now);
        $entity->setCreated($now);

        // Trigger oncreate
        $this->onCreate($entity);

        // Save
        $this->getEntityManager()->persist($entity);
        return $this->save($this->getEntityName() . ' created.', 'Unable to create ' . strtolower($this->getEntityName()) . '.');
    }
728842
public function beforeSave($insert)
    {
        if(parent::beforeSave($insert))
        {
            $this->updated_at = time();
            $this->translit();
            if($this->isNewRecord)
            {
                $this->created_at = $this->updated_at;
            }
            return true;
        }
        else
            return false;
    }
85711
function preSave($create = false)
    {
        if ($this->id == '') {
            $this->creationTime = gmdate('Y-m-d H:i:s');
        }
        $this->modifTime = gmdate('Y-m-d H:i:s');
        // File path
        $path = $this->getAbsloutPath();
        // file size
        if (file_exists($path)) {
            $this->fileSize = filesize($path);
        } else {
            $this->fileSize = 0;
        }
        // mime type (based on file name)
        $fileInfo = Pluf_FileUtil::getMimeType($this->fileName);
        $this->mimeType = $fileInfo[0];
    }
647056
private function create()
    {
        restoreRequest();
        $form = array(
            'name'=>'UserForm',
            'caption' => admUsersCreate,
            'width' => '400px',
            'fields' => array (
                array('type'=>'hidden','name'=>'action','value'=>'insert'),
                array('type'=>'edit','name'=>'name','label'=>admUsersName,'maxlength'=>32,'width'=>'100%',
                    'pattern'=>'/.+/', 'errormsg'=>admUsersNameInvalid),
                array('type'=>'edit','name'=>'login','label'=>admUsersLogin,'maxlength'=>16,'width'=>'100%',
                    'pattern'=>'/^[a-z0-9_]+$/i', 'errormsg'=>admUsersLoginInvalid),
                array('type'=>'select','name'=>'access','label'=>admAccessLevel, 'width'=>'100%',
                    'values'=>array('2','3','4'),'items'=>array(ACCESSLEVEL2,ACCESSLEVEL3,ACCESSLEVEL4),
                    'default' => USER),
                array('type'=>'checkbox','name'=>'active','label'=>admUsersAccountState, 'default' => true),
                array('type'=>'divider'),
                array('type'=>'password','name'=>'pswd1','label'=>admUsersPassword,'maxlength'=>32,
                    'width'=>'100%'),
                array('type'=>'password','name'=>'pswd2','label'=>admUsersConfirmation,'maxlength'=>32,
                    'width'=>'100%', 'equal'=>'pswd1', 'errormsg'=>admUsersConfirmInvalid),
                array('type'=>'divider'),
                array('type' => 'edit', 'name' => 'mail' , 'label' => admUsersMail,
                    'maxlength' => 32, 'width' => '100%'),
            ),
            'buttons'=>array('ok', 'cancel')
        );

        /** @var TAdminUI $page */
        $page = Eresus_Kernel::app()->getPage();
        $result = $page->renderForm($form, Eresus_CMS::getLegacyKernel()->request['arg']);
        return $result;
    }
654539
function $true(params) {
    if (typeof params === 'boolean') {
        return params;
    }
    if (typeof params === 'number') {
        return params === 1;
    }
    if (typeof params === 'string') {
        params = params.trim();

        return params.toLowerCase() === 'true' || params === '1';
    }

    return false;
}
544268
public function forceCreate(): bool {
        if (!$this->isFile()) {
            return \mkdir($this->path, 0744, true);
        }
        if ($this->isFile() && !$this->isWritable()) {
            $user = \get_current_user();
            return \chown($this->path, $user);
        }
        return false;
    }
741351
public function SetFormSaved($Saved = TRUE) {
      if ($Saved === '') // Allow reset
         $this->_FormSaved = '';
      else // Force true/false
         $this->_FormSaved = ($Saved) ? TRUE : FALSE;
   }
1190481
public function beforeCreate()
    {
        $this->timestamp_create = time();
        $this->timestamp_update = 0;
        $this->create_user_id = Module::getAuthorUserId();
        $this->update_user_id = Module::getAuthorUserId();
        $this->slugifyAlias();
    }
1102851
function preSave($create = false)
    {
        if ($this->id == '') {
            $this->creation_dtime = gmdate('Y-m-d H:i:s');
        }
        $this->modif_dtime = gmdate('Y-m-d H:i:s');
        // File path
        $path = $this->getAbsloutPath();
        // file size
        if (file_exists($path)) {
            $this->file_size = filesize($path);
        } else {
            $this->file_size = 0;
        }
        // mime type (based on file name)
        $mime_type = $this->mime_type;
        if (! isset($mime_type) || $mime_type === 'application/octet-stream') {
            $fileInfo = Pluf_FileUtil::getMimeType($this->file_name);
            $this->mime_type = $fileInfo[0];
        }
    }
976070
public function postCreate(CreateEvent $event)
    {
        /** @var Role $role */
        $role = $event->getObject();

        if ($role->getWorkspace()) {
            $sql = "
              INSERT INTO claro_resource_rights (role_id, mask, resourceNode_id)
              SELECT {$role->getId()}, 1, resource.id FROM claro_resource_node resource
              WHERE resource.workspace_id = {$role->getWorkspace()->getId()}
            ";

            $stmt = $this->conn->prepare($sql);
            $stmt->execute();
        }
    }
842178
public function create () : bool
	{
        $dbObject 	= Database::getInstance();
		$attributes = $this->sanitizedAttributes();
		$sqlQuery	= "INSERT INTO ".static::$tableName." (";
		$sqlQuery  .= join(", ", array_keys($attributes));
	  	$sqlQuery  .= ") VALUES ('";
		$sqlQuery  .= join("', '", array_values($attributes));
		$sqlQuery  .= "')";
		$result 	= $dbObject->query($sqlQuery);
    	$this->id 	= $dbObject->insertId();
    	return ($result) ? TRUE : FALSE;
	}
728355
public function getSession($create = false)
    {

        // load the proposed session-ID and name
        $id = $this->getProposedSessionId();
        $sessionName = $this->getRequestedSessionName();

        // if no session has already been load, initialize the session manager
        /** @var \AppserverIo\Appserver\ServletEngine\SessionManagerInterface $manager */
        $manager = $this->getSessionManager();

        // if no session manager was found, we don't support sessions
        if ($manager == null) {
            return;
        }

        // find or create a new session (if flag has been set)
        $session = $manager->find($id);

        // if we can't find a session or session has been expired and we want to create a new one
        if ($session == null && $create === true) {
            // check if a session ID has been specified
            if ($id == null) {
                // if not, generate a unique one
                $id = SessionUtils::generateRandomString();
            }

            // create a new session and register ID in request
            $session = $manager->create($id, $sessionName);
        }

        // if we can't find a session and we should NOT create one, return nothing
        if ($create === false && $session == null) {
            return;
        }

        // if we can't find a session although we SHOULD create one, we throw an exception
        if ($create === true && $session == null) {
            throw new \Exception('Can\'t create a new session!');
        }

        // initialize the session wrapper
        $wrapper = new SessionWrapper();
        $wrapper->injectSession($session);
        $wrapper->injectRequest($this);

        // set the session ID in the execution environment
        Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $id);

        // return the found session
        return $wrapper;
    }
952215
public function action_create( $params )
	{
		$name = array_shift( $params );
		
		$file = \DB\Migrator::path( $name );
		
		\CCFile::write( $file, "# ---> up\n\n\n\n# ---> down\n\n" );
	}
1039841
public function setProperties($properties, $create = FALSE){
        foreach ($properties as $key => $value) {
            $this->setProperty($key, $value, $create);
        }
    }
1138822
public function setCreated($created)
    {
        $this->created = $created instanceof \DateTime ? $created->format('Y-m-d H:i:s') : $created;

        return $this;
    }
1224230
function created($new = null)
    {
        if (isset($new) && ($this->_attributes['created'] != $new)){
            $this->change('created', (int)$new);
        }
        return $this->_attributes['created'];
    }