コード例 #1
0
 /**
  * Set password value
  *
  * @param string $value
  * @return boolean
  */
 function setPassword($value)
 {
     do {
         $salt = substr(sha1(uniqid(rand(), true)), rand(0, 25), 13);
         $token = sha1($salt . $value);
     } while (Contacts::tokenExists($token));
     $this->setToken($token);
     $this->setSalt($salt);
     $this->setTwister(StringTwister::getTwister());
 }
コード例 #2
0
 function ical_export()
 {
     $this->setLayout('ical');
     require_once ROOT . '/environment/classes/event/CalFormatUtilities.php';
     if (!isset($_GET['t']) || !isset($_GET['cal'])) {
         header('HTTP/1.0 404 Not Found');
         die;
     }
     $token = $_GET['t'];
     $cal = $_GET['cal'];
     if (Contacts::tokenExists($token)) {
         $user = Contacts::findOne(array('conditions' => "token='{$token}'"));
         $conditions = " AND EXISTS (SELECT i.contact_id FROM " . TABLE_PREFIX . "event_invitations i WHERE i.event_id=e.object_id AND  i.contact_id=" . $user->getId() . ")";
         if (array_var($_GET, 'cal') != "") {
             $mem_cond = "e.object_id IN (SELECT object_id FROM " . TABLE_PREFIX . "object_members WHERE member_id IN (" . array_var($_GET, 'cal') . "))";
         } else {
             $mem_cond = "true";
         }
         $user_pgs = $user->getPermissionGroupIds();
         $perm_cond = " AND EXISTS (SELECT st.object_id FROM " . TABLE_PREFIX . "sharing_table st WHERE st.object_id=e.object_id AND st.group_id IN (" . implode(',', $user_pgs) . "))";
         $events = ProjectEvents::findAll(array('conditions' => "{$mem_cond} {$perm_cond} {$conditions}"));
         $calendar_name = isset($_GET['n']) ? $_GET['n'] : $user->getObjectName();
         $calendar_name = str_replace(' ', '_', $calendar_name);
         $content = CalFormatUtilities::generateICalInfo($events, $calendar_name, $user);
         tpl_assign('content', $content);
     } else {
         header('HTTP/1.0 404 Not Found');
         die;
     }
 }