コード例 #1
0
ファイル: Save.php プロジェクト: joerch/PHProjekt
 /**
  * Check if the user has write access to the item if is not a global module.
  *
  * @param Phprojekt_Model_Interface $model      The model to save.
  * @param string                    $moduleName The current module.
  *
  * @return boolean False if not.
  */
 private static function _checkItemRights($model, $moduleName)
 {
     $canWrite = false;
     if ($moduleName == 'Core') {
         return Phprojekt_Auth::isAdminUser();
     } else {
         if (Phprojekt_Module::saveTypeIsNormal(Phprojekt_Module::getId($moduleName))) {
             $itemRights = $model->getRights();
             if (isset($itemRights['currentUser'])) {
                 if (!$itemRights['currentUser']['write'] && !$itemRights['currentUser']['create'] && !$itemRights['currentUser']['copy'] && !$itemRights['currentUser']['admin']) {
                     $canWrite = false;
                 } else {
                     $canWrite = true;
                 }
             }
         } else {
             $canWrite = true;
         }
     }
     return $canWrite;
 }
コード例 #2
0
 /**
  * Returns some params for the body of the notification
  * according to the current module and the event we are informing to the users.
  *
  * @return array Array with options.
  */
 public function getBodyParams()
 {
     $bodyParams = array();
     // Action
     switch ($this->_lastHistory[0]['action']) {
         case self::LAST_ACTION_ADD:
             $bodyParams['actionLabel'] = "created";
             break;
         case self::LAST_ACTION_EDIT:
         default:
             $bodyParams['actionLabel'] = "modified";
             break;
     }
     // Module
     $bodyParams['moduleTable'] = $this->_model->getModelName();
     // Url
     $url = "index.php#" . $this->_model->getModelName();
     if (Phprojekt_Module::saveTypeIsNormal(Phprojekt_Module::getId($this->_model->getModelName()))) {
         $url .= "," . $this->_model->projectId;
     }
     $url .= ",id," . $this->_model->id;
     $bodyParams['url'] = $url;
     return $bodyParams;
 }
コード例 #3
0
ファイル: Delete.php プロジェクト: RainyBlueSky/PHProjekt
 /**
  * Check if the user has delete access to the item if is not a global module.
  *
  * @param Phprojekt_ActiveRecord_Abstract $model      The model to save.
  * @param string                          $moduleName The current module.
  *
  * @return boolean True for a valid right.
  */
 private static function _checkItemRights(Phprojekt_ActiveRecord_Abstract $model, $moduleName)
 {
     $canDelete = false;
     if ($moduleName == 'Core') {
         return Phprojekt_Auth::isAdminUser();
     } else {
         if (Phprojekt_Module::saveTypeIsNormal(Phprojekt_Module::getId($moduleName)) && method_exists($model, 'hasRight')) {
             return $model->hasRight(Phprojekt_Auth_Proxy::getEffectiveUserId(), Phprojekt_Acl::DELETE);
         } else {
             return true;
         }
     }
 }
コード例 #4
0
ファイル: Save.php プロジェクト: RainyBlueSky/PHProjekt
 /**
  * Check if the parent project has this module enabled.
  *
  * @param integer $projectId The project ID to check.
  *
  * @return boolean False if not.
  */
 private static function _checkModule($moduleId, $projectId)
 {
     if ($projectId <= 0 || !Phprojekt_Module::saveTypeIsNormal($moduleId)) {
         return true;
     }
     $relation = new Project_Models_ProjectModulePermissions();
     $modules = $relation->getProjectModulePermissionsById($projectId);
     return !empty($modules['data'][$moduleId]['inProject']);
 }