コード例 #1
0
 /**
  * Determine if this user / forum combo can hard delete
  *
  * @param	integer	Forum ID
  * @param	array	Topic information
  * @return	integer Boolean
  */
 public function canHardDeleteTopics($fid = 0, $topic)
 {
     if ($fid and $this->_memberData['is_mod'] and !empty($this->_memberData['forumsModeratorData'][$fid]['delete_topic'])) {
         return TRUE;
     } elseif ($topic['starter_id'] == $this->_memberData['member_id'] and $this->_memberData['g_delete_own_topics']) {
         return TRUE;
     } else {
         return IPSMember::canModerateContent($this->_memberData, IPSMember::CONTENT_DELETE, $topic['starter_id']);
     }
 }
コード例 #2
0
ファイル: events.php プロジェクト: mover5/imobackup
 /**
  * Perform a permission check
  *
  * @param	string	Type of check (add/edit/delete/editall/deleteall/approve all)
  * @param	array 	Array of GENERIC data
  * @return	true or string to be used in exception
  */
 public function can($type, array $array)
 {
     /* Init */
     $comment = array();
     /* Got data? */
     if (empty($array['comment_parent_id'])) {
         trigger_error("No parent ID passed to " . __FILE__, E_USER_WARNING);
     }
     /* Get the file */
     $event = $this->fetchParent($array['comment_parent_id']);
     /* Fetch comment */
     if ($array['comment_id']) {
         $comment = $this->fetchById($array['comment_id']);
     }
     /* Check permissions */
     switch ($type) {
         case 'view':
             if (!$this->registry->permissions->check('view', $event)) {
                 return 'NO_PERMISSION';
             }
             if ($event['event_private'] and (!$this->memberData['member_id'] or $this->memberData['member_id'] != $event['event_member_id'])) {
                 return 'NO_PERMISSION';
             }
             if ($event['event_perms'] != '*') {
                 $permissionGroups = explode(',', IPSText::cleanPermString($event['event_perms']));
                 if (!IPSMember::isInGroup($this->memberData, $permissionGroups)) {
                     return 'NO_PERMISSION';
                 }
             }
             return true;
             break;
         case 'edit':
             if (!$this->registry->permissions->check('comment', $event)) {
                 return 'NO_PERMISSION';
             }
             if (!$this->memberData['g_is_supmod'] and ($this->memberData['member_id'] != $comment['comment_author_id'] or !$comment['comment_author_id'])) {
                 return 'NO_PERMISSION';
             }
             return true;
             break;
         case 'add':
             if (!$this->registry->permissions->check('comment', $event)) {
                 return 'NO_PERMISSION';
             }
             return true;
             break;
         case 'delete':
             return $this->memberData['g_is_supmod'] ? true : 'NO_PERMISSION';
             break;
         case 'visibility':
         case 'moderate':
             return $this->memberData['g_is_supmod'] ? true : 'NO_PERMISSION';
             break;
         case 'hide':
             return IPSMember::canModerateContent($this->memberData, IPSMember::CONTENT_HIDE, $comment['comment_author_id']) ? TRUE : 'NO_PERMISSION';
             break;
         case 'unhide':
             return IPSMember::canModerateContent($this->memberData, IPSMember::CONTENT_UNHIDE, $comment['comment_author_id']) ? TRUE : 'NO_PERMISSION';
             break;
     }
 }