Esempio n. 1
0
 /**
  * Creates the approved/unapproved symbol
  *
  * @param SPDataModel $row
  * @return string
  */
 public static function approval($row)
 {
     /* check state */
     $state = $row->get('approved') ? 1 : 0;
     SPLoader::loadClass('html.tooltip');
     /* get icons */
     $up = Sobi::Cfg('list_icons.unapproved');
     $pu = Sobi::Cfg('list_icons.approved');
     $img = $state == 1 ? $pu : $up;
     $action = $state ? $row->get('oType') . '.unapprove' : $row->get('oType') . '.approve';
     /* translate alternative text */
     $s = Sobi::Txt($row->get('oType') . '.approval_head');
     $a = Sobi::Txt('approval_' . ($state ? 'on' : 'off'));
     $img = SPTooltip::toolTip($a, $s, $img);
     /* if user has permission for this action */
     if (SPFactory::user()->can($action)) {
         $url = SPFactory::mainframe()->url(array('task' => $action, 'sid' => $row->get('id')));
         $img = "<a href=\"{$url}\">{$img}</a>";
     }
     return $img;
 }
Esempio n. 2
0
 /**
  */
 public function visible()
 {
     $type = $this->_model->get('oType');
     if (Sobi::Can($type, 'access', '*')) {
         return true;
     }
     $error = false;
     $owner = $this->_model->get('owner');
     $state = $this->_model->get('state');
     Sobi::Trigger($type, 'CheckVisibility', array(&$state, &$owner));
     /* if it's unpublished */
     if (!$state) {
         if ($owner == Sobi::My('id')) {
             if (!Sobi::Can($type, 'access', 'unpublished_own')) {
                 $error = true;
             }
         } else {
             if (!Sobi::Can($type, 'access', 'unpublished_any')) {
                 $error = true;
             }
         }
     } else {
         if (!Sobi::Can($type, 'access', 'valid')) {
             $error = true;
         }
     }
     /** if not approved */
     /** and unapproved entry can be accessed
      * because then the previously created version
      * should be displayed
      */
     if ($type == 'category') {
         $approved = $this->_model->get('approved');
         if (!$approved) {
             if (!Sobi::Can($type, 'access', 'unapproved_any')) {
                 $error = true;
             }
         }
     }
     /* if it's expired or not valid yet  */
     $va = $this->_model->get('validUntil');
     $va = $va ? strtotime($va . ' UTC') : 0;
     if (!$error) {
         if (strtotime($this->_model->get('validSince') . ' UTC') > gmdate('U')) {
             if ($owner == Sobi::My('id')) {
                 if (!Sobi::Can($type, 'access', 'unpublished_own')) {
                     $error = true;
                 }
             } else {
                 if (!Sobi::Can($type, 'access', 'unpublished_any')) {
                     $error = true;
                 }
             }
         } elseif ($va > 0 && $va < gmdate('U')) {
             if ($owner == Sobi::My('id')) {
                 if (!Sobi::Can($type, 'access', 'unpublished_own')) {
                     $error = true;
                 }
             } else {
                 if (!Sobi::Can($type, 'access', 'unpublished_any')) {
                     $error = true;
                 }
             }
         }
     }
     if ($error) {
         $redirect = Sobi::Cfg('redirects.' . $type . '_access_url', null);
         if (Sobi::Cfg('redirects.' . $type . '_access_enabled', false) && strlen($redirect)) {
             $this->escape($redirect, Sobi::Cfg('redirects.' . $type . '_access_msg', SPLang::e('UNAUTHORIZED_ACCESS', SPRequest::task())), Sobi::Cfg('redirects.' . $type . '_access_msgtype', 'message'));
             exit;
         } else {
             Sobi::Error($this->name(), SPLang::e('UNAUTHORIZED_ACCESS', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
         }
     }
 }