Esempio n. 1
0
    <button id="btnCollapseAll"><?php 
p($l->t('Collapse all'));
?>
</button>
    
    <?php 
p($l->t('Owner:'));
?>
    <select name="menuOwnName" id="menuOwnName" disabled="true">
        <option value='' disabled='disabled' selected='selected'><?php 
p($l->t('Not set'));
?>
</option>
        
        <?php 
$usersList = \OCA\OCLife\utilities::getUsers(NULL, TRUE);
foreach ($usersList as $uid => $userName) {
    printf("<option value='%s'>%s</option>'", $uid, is_null($userName) ? $uid : $userName);
}
?>
        
    </select>

    <select name="menuOwnPriv" id="menuOwnPriv" disabled="true">
        <option value="OwnRO"><?php 
p($l->t('Read only'));
?>
</option>
        <option value="OwnRW"><?php 
p($l->t('Can modify'));
?>
Esempio n. 2
0
 /**
  *  Check if provided tag id can be read by the provided user
  *  @param $tagid integer Tag id
  *  @param $user string Actual user; NULL pickup actual logged in user
  *  @return boolean TRUE if permission is valid, false otherwise
  */
 public static function readAllowed($tagid, $user = NULL)
 {
     // If owner is not set, assign the actual username
     if ($user === NULL) {
         $user = \OCP\User::getUser();
     }
     // If user is an administrator, read is allowed
     if (\OC_User::isAdminUser(\OCP\User::getUser())) {
         return TRUE;
     }
     // Query for actual tag's owner and permission
     $sql = "SELECT `owner`, `permission` FROM `*PREFIX*oclife_tags` WHERE `id`=?";
     $args = array($tagid);
     $query = \OCP\DB::prepare($sql);
     $resRsrc = $query->execute($args);
     $owner = NULL;
     $permission = NULL;
     while ($row = $resRsrc->fetchRow()) {
         // Legacy check on user and permission
         $permission = \OCA\OCLife\hTags::getPermission($row['permission']);
         $owner = isset($row['owner']) ? $row['owner'] : $user;
     }
     // Check if worldwide readable
     if (substr($permission, 4, 1) === 'r') {
         return TRUE;
     }
     // Check for operating on owner's tag
     if ($user === $owner) {
         return substr($permission, 0, 1) === 'r' ? TRUE : FALSE;
     }
     // Check for tags owned by group's companion where $user belongs to
     if (substr($permission, 2, 1) === 'r') {
         $userCompanion = \OCA\OCLife\utilities::getUsers($user);
         $groupPos = in_array($owner, $userCompanion);
         return $groupPos === FALSE ? FALSE : TRUE;
     } else {
         return FALSE;
     }
 }