当前位置: 首页>>代码示例>>PHP>>正文


PHP Application_Model_User::getId方法代码示例

本文整理汇总了PHP中Application_Model_User::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Application_Model_User::getId方法的具体用法?PHP Application_Model_User::getId怎么用?PHP Application_Model_User::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Application_Model_User的用法示例。


在下文中一共展示了Application_Model_User::getId方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 public function save(Application_Model_User $user)
 {
     $password = sha1($user->getPassword());
     $data = array('confirmed' => $user->getConfirmed(), 'created' => $user->getCreated(), 'email' => $user->getEmail(), 'id' => $user->getId(), 'name' => $user->getName(), 'password' => $password);
     if (null === ($id = $user->getId())) {
         unset($data['id']);
         return $this->getDbTable()->insert($data);
     } else {
         $this->getDbTable()->update($data, array('id = ?' => $id));
     }
 }
开发者ID:jingjangjung,项目名称:WinsAndWants,代码行数:11,代码来源:UserMapper.php

示例2: userCan

 /**
  * Still playing around with how I want to handle permissions.
  * This is a method that can be called before each action to 
  * see if the user can do what they are asking to.
  * 
  * @access public
  * @return void
  */
 protected function userCan()
 {
     // User can edit themselves
     if ($this->id == $this->user->getId()) {
         return true;
     }
     // TODO: Need to expand upon this? Probably...
     // we can add in what the user is trying to do, and check perms
     // on top of just ownership. This will do for now.
     if ($this->id) {
         if ($this->user->isParentOf($this->id) || $this->user->isSuperAdmin()) {
             return true;
         }
     } else {
         // If there was no id already set, we are probably adding a folder.
         // TODO: Need to handle perms somehow here.
         return true;
     }
     // Set this entity to not valid so we do not give anything away
     // TODO: Maybe make a default() method that we can reset a built entity to it's defaults.
     // defaults could be set from the entity profile.
     $this->valid = false;
     $this->error = 'User does not have permission to execute the request.';
     //$this->error = 'ID does not exist for this user.';
     return false;
 }
开发者ID:fniftaly,项目名称:Java-Selenium,代码行数:34,代码来源:Entityabstract.php

示例3: _isValid

 /**
  * Checks whether this contest ready to be saved.
  *  
  * @access protected
  * @return boolean
  */
 protected function _isValid()
 {
     if ($this->_user instanceof Application_Model_User) {
         if ($this->_user->getId()) {
             if ($this->_user->canCreateContest()) {
                 if ($this->name) {
                     if ($this->startdate && $this->enddate || $this->type == 3) {
                         if ($this->type) {
                             if ($this->already_played_msg && $this->before_contest_msg && $this->after_contest_msg) {
                                 return true;
                             } else {
                                 $this->setError('A contest requires a messages for before the contest, after the contest and already played subscibers.');
                             }
                         } else {
                             $this->setError('A contest type must be selected.');
                         }
                     } else {
                         $this->setError('You must enter a start and end date for this contest to run.');
                     }
                 } else {
                     $this->setError('You must name the contest.');
                 }
             } else {
                 $this->setError('User can not create Contests, upgrade to a Premium user for this feature.');
             }
         } else {
             $this->setError('Invalid user');
         }
     } else {
         $this->setError('A user must be supplied to create a contest');
     }
     return false;
 }
开发者ID:fniftaly,项目名称:Java-Selenium,代码行数:39,代码来源:Contest.php

示例4: loginAction

 public function loginAction()
 {
     if (Zend_Auth::getInstance()->hasIdentity()) {
         return $this->_redirect('/');
     }
     // process the form
     $form = new Application_Form_Login();
     if ($this->getRequest()->isPost() && $form->isValid($_POST)) {
         // check if the user exists
         $user_mapper = new Application_Model_UserMapper();
         $qry = "\n                SElECT *\n                FROM   user\n                WHERE  username = :credential\n                OR     email    = :credential";
         $params = array('credential' => $form->getValue('credential'));
         $user = $user_mapper->query($qry, $params);
         if ($user) {
             $user = new Application_Model_User($user[0]);
             // if the account is not active, prompt the user to activate the account
             if (!$user->getActive()) {
                 $this->_helper->FlashMessenger('User Not Activated');
                 return $this->_redirect('/registration/confirm/id/' . $user->getId());
             }
             // authenticate the user
             $db = Zend_Registry::get('db_default');
             $credential_choice = $params['credential'] == $user->getUsername() ? 'username' : 'email';
             $adapter = new Zend_Auth_Adapter_DbTable($db, 'user', $credential_choice, 'password_hash');
             $adapter->setIdentity($form->getValue('credential'));
             $adapter->setCredential(hash('sha256', $user->getPassword_salt() . $form->getValue('password')));
             $zend_auth = Zend_Auth::getInstance();
             $result = $zend_auth->authenticate($adapter);
             if ($result->isValid()) {
                 // store session information in database
                 $session_mapper = new Application_Model_SessionMapper();
                 $session = new Application_Model_Session(array('user_id' => $user->getId(), 'ip_address' => $_SERVER['REMOTE_ADDR'], 'login_timestamp' => date('Y-m-d H:i:s')));
                 $session_mapper->save($session);
                 // store user information in session variable
                 $session = new Zend_Session_Namespace('user');
                 $session->user = $user->get_array();
                 $this->_helper->FlashMessenger('Successful Login');
                 return $this->_redirect('/');
             } else {
                 echo "Authentication failed.";
             }
         } else {
             echo "Invalid username/email";
         }
     }
     $this->view->form = $form;
 }
开发者ID:alclin,项目名称:zend_framework,代码行数:47,代码来源:AuthController.php

示例5: save

 public function save(Application_Model_User $user)
 {
     $data = array('password' => $user->getPassword(), 'username' => $user->getUserName());
     if (null === ($id = $user->getId())) {
         unset($data['id']);
         $this->getDbTable()->insert($data);
     } else {
         $this->getDbTable()->update($data, array('id = ?' => $id));
     }
 }
开发者ID:BGCX262,项目名称:zwh-web-svn-to-git,代码行数:10,代码来源:UserMapper.php

示例6: save

 /**
  * Saves the session 
  * 
  * @access public
  * @return boolean True on success
  */
 public function save()
 {
     // Serialize the session data array
     $datastore = serialize($this->sessiondata);
     $userid = $this->user ? $this->user->getId() : '-1';
     $sql = "call session_update('{$this->id}', '{$this->requestip}', " . $userid . ", {$this->requesttime}, '{$this->requestpage}', '{$this->requestaction}', '{$datastore}')";
     $rs = $this->query($sql);
     if (!$this->error) {
         if (isset($rs->fields['success']) && $rs->fields['success'] == 1) {
             return true;
         }
         $this->error = 'Could not save the new session.';
     }
     $this->error = 'There was a general error saving this session.';
     return false;
 }
开发者ID:fniftaly,项目名称:Java-Selenium,代码行数:22,代码来源:Session.php

示例7: getValidationLink

 private function getValidationLink(Application_Model_User &$user)
 {
     if (getenv('APPLICATION_ENV') == 'development') {
         return 'http://localhost' . $this->view->baseUrl() . '/auth/confirm/id/' . $user->getId();
     } else {
         return 'http://winsandwants.com' . $this->view->baseUrl() . '/auth/confirm/id/' . $user->getId();
     }
 }
开发者ID:jingjangjung,项目名称:WinsAndWants,代码行数:8,代码来源:AuthController.php

示例8: _isValid

 /**
  * Checks whether this keyword is a valid keyword or not... useful for 
  * saving edits
  * 
  * REQUIRED ELEMENTS:
  *  - Keyword
  *  - Folder id that user is parent of
  *  - Reply body
  *  
  * @access protected
  * @return boolean
  */
 protected function _isValid()
 {
     if ($this->folderid) {
         if ($this->_user instanceof Application_Model_User && $this->_user->getId() && $this->_user->isParentOf($this->folderid)) {
             if ($this->replybody) {
                 return true;
             } else {
                 $this->setError('A keyword requires a auto response message');
             }
         } else {
             $this->setError('Permission denied');
         }
     } else {
         $this->setError('A keyword must be added to a folder');
     }
     return false;
 }
开发者ID:fniftaly,项目名称:Java-Selenium,代码行数:29,代码来源:Keyword.php

示例9: contextMenuAction

 public function contextMenuAction()
 {
     $id = $this->_getParam('id');
     $type = $this->_getParam('type');
     //playlist||timeline
     $screen = $this->_getParam('screen');
     $request = $this->getRequest();
     $baseUrl = $request->getBaseUrl();
     $menu = array();
     $userInfo = Zend_Auth::getInstance()->getStorage()->read();
     $user = new Application_Model_User($userInfo->id);
     //Open a jPlayer window and play the audio clip.
     $menu["play"] = array("name" => "Preview", "icon" => "play", "disabled" => false);
     $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
     $obj_sess = new Zend_Session_Namespace(UI_PLAYLISTCONTROLLER_OBJ_SESSNAME);
     if ($type === "audioclip") {
         $file = Application_Model_StoredFile::Recall($id);
         $menu["play"]["mime"] = $file->getPropelOrm()->getDbMime();
         if (isset($obj_sess->id) && $screen == "playlist") {
             // if the user is not admin or pm, check the creator and see if this person owns the playlist or Block
             if ($obj_sess->type == 'playlist') {
                 $obj = new Application_Model_Playlist($obj_sess->id);
             } elseif ($obj_sess->type == 'block') {
                 $obj = new Application_Model_Block($obj_sess->id);
             }
             if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
                 if ($obj_sess->type === "playlist") {
                     $menu["pl_add"] = array("name" => "Add to Playlist", "icon" => "add-playlist", "icon" => "copy");
                 } elseif ($obj_sess->type === "block") {
                     $menu["pl_add"] = array("name" => "Add to Smart Block", "icon" => "add-playlist", "icon" => "copy");
                 }
             }
         }
         if ($isAdminOrPM) {
             $menu["del"] = array("name" => "Delete", "icon" => "delete", "url" => "/library/delete");
             $menu["edit"] = array("name" => "Edit Metadata", "icon" => "edit", "url" => "/library/edit-file-md/id/{$id}");
         }
         $url = $file->getRelativeFileUrl($baseUrl) . '/download/true';
         $menu["download"] = array("name" => "Download", "icon" => "download", "url" => $url);
     } elseif ($type === "playlist" || $type === "block") {
         if ($type === 'playlist') {
             $obj = new Application_Model_Playlist($id);
         } elseif ($type === 'block') {
             $obj = new Application_Model_Block($id);
             if (!$obj->isStatic()) {
                 unset($menu["play"]);
             }
             if (($isAdminOrPM || $obj->getCreatorId() == $user->getId()) && $screen == "playlist") {
                 if ($obj_sess->type === "playlist") {
                     $menu["pl_add"] = array("name" => "Add to Playlist", "icon" => "add-playlist", "icon" => "copy");
                 }
             }
         }
         if ($obj_sess->id !== $id && $screen == "playlist") {
             if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
                 $menu["edit"] = array("name" => "Edit", "icon" => "edit");
             }
         }
         if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
             $menu["del"] = array("name" => "Delete", "icon" => "delete", "url" => "/library/delete");
         }
     } elseif ($type == "stream") {
         $webstream = CcWebstreamQuery::create()->findPK($id);
         $obj = new Application_Model_Webstream($webstream);
         if (isset($obj_sess->id) && $screen == "playlist") {
             if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
                 if ($obj_sess->type === "playlist") {
                     $menu["pl_add"] = array("name" => "Add to Playlist", "icon" => "add-playlist", "icon" => "copy");
                 }
             }
         }
         if ($isAdminOrPM || $obj->getCreatorId() == $user->getId()) {
             if ($screen == "playlist") {
                 $menu["edit"] = array("name" => "Edit", "icon" => "edit", "url" => "/library/edit-file-md/id/{$id}");
             }
             $menu["del"] = array("name" => "Delete", "icon" => "delete", "url" => "/library/delete");
         }
     }
     //SOUNDCLOUD MENU OPTIONS
     if ($type === "audioclip" && Application_Model_Preference::GetUploadToSoundcloudOption()) {
         //create a menu separator
         $menu["sep1"] = "-----------";
         //create a sub menu for Soundcloud actions.
         $menu["soundcloud"] = array("name" => "Soundcloud", "icon" => "soundcloud", "items" => array());
         $scid = $file->getSoundCloudId();
         if ($scid > 0) {
             $url = $file->getSoundCloudLinkToFile();
             $menu["soundcloud"]["items"]["view"] = array("name" => "View on Soundcloud", "icon" => "soundcloud", "url" => $url);
         }
         if (!is_null($scid)) {
             $text = "Re-upload to SoundCloud";
         } else {
             $text = "Upload to SoundCloud";
         }
         $menu["soundcloud"]["items"]["upload"] = array("name" => $text, "icon" => "soundcloud", "url" => "/library/upload-file-soundcloud/id/{$id}");
     }
     if (empty($menu)) {
         $menu["noaction"] = array("name" => "No action available");
     }
     $this->view->items = $menu;
//.........这里部分代码省略.........
开发者ID:nidzix,项目名称:Airtime,代码行数:101,代码来源:LibraryController.php

示例10: delete

 /**
  * Delete stored virtual file
  *
  * @param boolean $p_deleteFile
  *
  */
 public function delete()
 {
     $filepath = $this->getFilePath();
     // Check if the file is scheduled to be played in the future
     if (Application_Model_Schedule::IsFileScheduledInTheFuture($this->getId())) {
         throw new DeleteScheduledFileException();
     }
     $userInfo = Zend_Auth::getInstance()->getStorage()->read();
     $user = new Application_Model_User($userInfo->id);
     $isAdminOrPM = $user->isUserType(array(UTYPE_ADMIN, UTYPE_PROGRAM_MANAGER));
     if (!$isAdminOrPM && $this->getFileOwnerId() != $user->getId()) {
         throw new FileNoPermissionException();
     }
     $music_dir = Application_Model_MusicDir::getDirByPK($this->_file->getDbDirectory());
     $type = $music_dir->getType();
     if (file_exists($filepath) && $type == "stor") {
         $data = array("filepath" => $filepath, "delete" => 1);
         try {
             Application_Model_RabbitMq::SendMessageToMediaMonitor("file_delete", $data);
         } catch (Exception $e) {
             Logging::error($e->getMessage());
             return;
         }
     }
     // set hidden flag to true
     $this->_file->setDbHidden(true);
     $this->_file->save();
     // need to explicitly update any playlist's and block's length
     // that contains the file getting deleted
     $fileId = $this->_file->getDbId();
     $plRows = CcPlaylistcontentsQuery::create()->filterByDbFileId()->find();
     foreach ($plRows as $row) {
         $pl = CcPlaylistQuery::create()->filterByDbId($row->getDbPlaylistId($fileId))->findOne();
         $pl->setDbLength($pl->computeDbLength(Propel::getConnection(CcPlaylistPeer::DATABASE_NAME)));
         $pl->save();
     }
     $blRows = CcBlockcontentsQuery::create()->filterByDbFileId($fileId)->find();
     foreach ($blRows as $row) {
         $bl = CcBlockQuery::create()->filterByDbId($row->getDbBlockId())->findOne();
         $bl->setDbLength($bl->computeDbLength(Propel::getConnection(CcBlockPeer::DATABASE_NAME)));
         $bl->save();
     }
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:49,代码来源:StoredFile.php


注:本文中的Application_Model_User::getId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。