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


PHP SPRequest::timestamp方法代码示例

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


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

示例1: save

 /**
  * Save a rule
  *
  * @param bool $apply
  */
 protected function save($apply)
 {
     Sobi::Trigger('Save', 'Acl', array(&$this));
     if (!SPFactory::mainframe()->checkToken()) {
         Sobi::Error('Token', SPLang::e('UNAUTHORIZED_ACCESS_TASK', SPRequest::task()), SPC::ERROR, 403, __LINE__, __FILE__);
     }
     $rid = SPRequest::int('rid', 'null');
     $this->validate('acl.edit', array('task' => 'acl.edit', 'rid' => $rid));
     if ($rid) {
         $this->remove($rid);
     }
     $vs = SPRequest::timestamp('set_validSince');
     $vu = SPRequest::timestamp('set_validUntil');
     $vs = $vs ? date(Sobi::Cfg('db.date_format', 'Y-m-d H:i:s'), $vs) : null;
     $vu = $vu ? date(Sobi::Cfg('db.date_format', 'Y-m-d H:i:s'), $vu) : null;
     $name = SPRequest::string('set_name');
     $nid = SPRequest::cmd('set_nid');
     $note = SPRequest::string('set_note');
     $state = SPRequest::int('set_state', 1);
     $gids = SPRequest::arr('set_groups');
     $sids = SPRequest::arr('set_sections');
     $pf = SPRequest::arr('set_permissions', array());
     $pa = SPRequest::arr('set_adm_permissions', array());
     // if can publish any, then can see any unpublished
     if (in_array(20, $pf)) {
         $pf[] = 14;
     }
     // if can publish own, then can see own unpublished
     if (in_array(21, $pf)) {
         $pf[] = 12;
     }
     if (in_array(19, $pf)) {
         $pf[] = 15;
     }
     $perms = array_merge($pf, $pa);
     /* @var SPdb $db */
     $db = SPFactory::db();
     /* update or insert the rule definition */
     try {
         $db->insertUpdate('spdb_permissions_rules', array('rid' => $rid, 'name' => $name, 'nid' => $nid, 'validSince' => $vs, 'validUntil' => $vu, 'note' => $note, 'state' => $state));
     } catch (SPException $x) {
         Sobi::Error('ACL', SPLang::e('CANNOT_CREATE_RULE_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     $rid = (int) $rid ? (int) $rid : $db->insertid();
     /* insert the groups ids */
     if (count($gids)) {
         foreach ($gids as $i => $gid) {
             $gids[$i] = array('rid' => $rid, 'gid' => $gid);
         }
         try {
             $db->insertArray('spdb_permissions_groups', $gids);
         } catch (SPException $x) {
             Sobi::Error('ACL', SPLang::e('CANNOT_INSERT_GROUPS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
     try {
         $db->select('*', 'spdb_permissions', array('site' => 'adm', 'value' => 'global'));
         $admPermissions = $db->loadResultArray();
     } catch (SPException $x) {
         Sobi::Error('ACL', SPLang::e('CANNOT_GET_PERMISSIONS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     /* create permission and section map */
     if (count($sids) && count($perms)) {
         $map = array();
         /* travel the sections */
         foreach ($sids as $sid) {
             foreach ($perms as $pid) {
                 if (in_array($pid, $admPermissions)) {
                     $map[] = array('rid' => $rid, 'sid' => 0, 'pid' => $pid);
                 } else {
                     $map[] = array('rid' => $rid, 'sid' => $sid, 'pid' => $pid);
                 }
             }
         }
         try {
             $db->insertArray('spdb_permissions_map', $map, true);
         } catch (SPException $x) {
             Sobi::Error('ACL', SPLang::e('CANNOT_INSERT_GROUPS_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
     SPFactory::cache()->cleanAll();
     /* trigger plugins */
     Sobi::Trigger('AfterSave', 'Acl', array(&$this));
     /* set redirect */
     $this->response(Sobi::Url($apply ? array('task' => 'acl.edit', 'rid' => $rid) : 'acl'), Sobi::Txt('ACL_RULE_SAVED'), !$apply, SPC::SUCCESS_MSG, array('sets' => array('rid' => $rid)));
 }
开发者ID:vstorm83,项目名称:propertease,代码行数:91,代码来源:acl.php


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