Example #1
0
    public function store()
    {
        global $g_pdo;
        parent::store();
        $request = <<<EOF
INSERT INTO `item_ticket`
SET
\t`obj_id`= :obj_id,
\t`event_name`= :event_name,
\t`event_rate_name`= :event_rate_name,
\t`event_rate_amount`= :event_rate_amount,
\t`event_rate_tax`= :event_rate_tax,
\t`attendee_firstname`= :attendee_firstname,
\t`attendee_lastname`= :attendee_lastname,
\t`attendee_title`= :attendee_title,
\t`id_ticket`= :id_ticket
EOF;
        $pst = $g_pdo->prepare($request);
        $array = array(":obj_id" => $this->id, ":event_name" => $this->event_name, ":event_rate_name" => $this->event_rate_name, ":event_rate_amount" => $this->event_rate_amount, ":event_rate_tax" => $this->event_rate_tax, ":attendee_firstname" => $this->attendee_firstname, ":attendee_lastname" => $this->attendee_lastname, ":attendee_title" => $this->attendee_title, ":id_ticket" => $this->ticket_id);
        $pst->execute($array);
    }
 /**
  * Overriden store() method to set status to finished if rcpcount is 0
  */
 public function store()
 {
     if ($this->get("rcpcount") == 0) {
         // No recipients, job finished
         $this->set("status", 9);
         if ($this->get("started") == "0000-00-00 00:00:00") {
             $this->set("started", date("Y-m-d H:i:s"), false);
         }
         $this->set("finished", date("Y-m-d H:i:s"), false);
     }
     parent::store();
 }
 /**
  * Overriden store()-Method to set modified and modifiedby data and
  * to ensure, that there is only one welcome newsletter
  */
 public function store()
 {
     global $client, $lang, $auth;
     $client = Contenido_Security::toInteger($client);
     $lang = Contenido_Security::toInteger($lang);
     $this->set("modified", date("Y-m-d H:i:s"), false);
     $this->set("modifiedby", $auth->auth["uid"]);
     if ($this->get("welcome") == 1) {
         $oItems = new NewsletterCollection();
         $oItems->setWhere("idclient", $client);
         $oItems->setWhere("idlang", $lang);
         $oItems->setWhere("welcome", 1);
         $oItems->setWhere("idnews", $this->get("idnews"), "<>");
         $oItems->query();
         while ($oItem = $oItems->next()) {
             $oItem->set("welcome", 0);
             $oItem->store();
         }
         unset($oItem);
         unset($oItems);
     }
     parent::store();
 }
 /**
  * Overriden store() method to ensure, that there is only one default group
  **/
 public function store()
 {
     global $client, $lang;
     $client = Contenido_Security::toInteger($client);
     $lang = Contenido_Security::toInteger($lang);
     if ($this->get("defaultgroup") == 1) {
         $oItems = new RecipientGroupCollection();
         $oItems->setWhere("idclient", $client);
         $oItems->setWhere("idlang", $lang);
         $oItems->setWhere("defaultgroup", 1);
         $oItems->setWhere("idnewsgroup", $this->get("idnewsgroup"), "<>");
         $oItems->query();
         while ($oItem = $oItems->next()) {
             $oItem->set("defaultgroup", 0);
             $oItem->store();
         }
     }
     parent::store();
 }
 /**
  * setCatLang sets the idcatlang for the current item. Should
  * only be called by the create function.
  * @param int $idcatlang idcatlang to set.
  */
 function setCatLang($idcatlang)
 {
     global $cfg;
     $allocations = new WorkflowAllocations();
     $allocations->select("idcatlang = '{$idcatlang}'");
     if ($allocations->next() !== false) {
         $this->lasterror = i18n("Category already has a workflow assigned", "workflow");
         return false;
     }
     $db = new DB_Contenido();
     $sql = "SELECT idcatlang FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcatlang = '" . Contenido_Security::toInteger($idcatlang) . "'";
     $db->query($sql);
     if (!$db->next_record()) {
         $this->lasterror = i18n("Category doesn't exist, assignment failed", "workflow");
         return false;
     }
     parent::setField("idcatlang", $idcatlang);
     parent::store();
     return true;
 }
 /**
  * setPosition Sets the position for an item. Should only be 
  * called by the "swap" function
  * @param int $idposition The new position ID
  */
 function setPosition($idposition)
 {
     parent::setField("position", $idposition);
     parent::store();
     return true;
 }
 /**
  * Overriden store function to send mails 
  * @param none
  */
 function store()
 {
     global $cfg, $encoding, $lang;
     $sMailhost = getSystemProperty('system', 'mail_host');
     if ($sMailhost == '') {
         $sMailhost = 'localhost';
     }
     //modified : 2008-06-25 - use php mailer class instead of mail()
     $oMail = new PHPMailer();
     $oMail->CharSet = isset($encoding[$lang]) ? $encoding[$lang] : 'UTF-8';
     $oMail->Host = $sMailhost;
     $oMail->IsHTML(0);
     $oMail->WordWrap = 1000;
     $oMail->IsMail();
     if (array_key_exists("idusersequence", $this->modifiedValues)) {
         $usersequence = new WorkflowUserSequence();
         $usersequence->loadByPrimaryKey($this->values["idusersequence"]);
         $email = $usersequence->get("emailnoti");
         $escal = $usersequence->get("escalationnoti");
         if ($email == 1 || $escal == 1) {
             /* Grab the required informations */
             $curEditor = getGroupOrUserName($usersequence->get("iduser"));
             $idartlang = $this->get("idartlang");
             $timeunit = $usersequence->get("timeunit");
             $timelimit = $usersequence->get("timelimit");
             $db = new DB_Contenido();
             $sql = "SELECT author, title, idart FROM " . $cfg["tab"]["art_lang"] . " WHERE idartlang = '" . Contenido_Security::escapeDB($idartlang, $db) . "'";
             $db->query($sql);
             if ($db->next_record()) {
                 $idart = $db->f("idart");
                 $title = $db->f("title");
                 $author = $db->f("author");
             }
             /* Extract category */
             $sql = "SELECT idcat FROM " . $cfg["tab"]["cat_art"] . " WHERE idart = '" . Contenido_Security::escapeDB($idart, $db) . "'";
             $db->query($sql);
             if ($db->next_record()) {
                 $idcat = $db->f("idcat");
             }
             $sql = "SELECT name FROM " . $cfg["tab"]["cat_lang"] . " WHERE idcat = '" . Contenido_Security::escapeDB($idcat, $db) . "'";
             $db->query($sql);
             if ($db->next_record()) {
                 $catname = $db->f("name");
             }
             $starttime = $this->get("starttime");
             $starttime = strtotime(substr_replace(substr(substr($starttime, 0, 2) . chunk_split(substr($starttime, 2, 6), 2, "-") . chunk_split(substr($starttime, 8), 2, ":"), 0, 19), " ", 10, 1));
             switch ($timeunit) {
                 case "Seconds":
                     $maxtime = $starttime + $timelimit;
                     break;
                 case "Minutes":
                     $maxtime = $starttime + $timelimit * 60;
                     break;
                 case "Hours":
                     $maxtime = $starttime + $timelimit * 3600;
                     break;
                 case "Days":
                     $maxtime = $starttime + $timelimit * 86400;
                     break;
                 case "Weeks":
                     $maxtime = $starttime + $timelimit * 604800;
                     break;
                 case "Months":
                     $maxtime = $starttime + $timelimit * 2678400;
                     break;
                 case "Years":
                     $maxtime = $starttime + $timelimit * 31536000;
                     break;
                 default:
                     $maxtime = $starttime + $timelimit;
             }
             if ($email == 1) {
                 $email = i18n("Hello %s,\n\n" . "you are assigned as the next editor for the Article %s.\n\n" . "More informations:\n" . "Article: %s\n" . "Category: %s\n" . "Editor: %s\n" . "Author: %s\n" . "Editable from: %s\n" . "Editable to: %s\n");
                 $filledMail = sprintf($email, $curEditor, $title, $title, $catname, $curEditor, $author, date("Y-m-d H:i:s", $starttime), date("Y-m-d H:i:s", $maxtime));
                 $user = new User();
                 if (isGroup($usersequence->get("iduser"))) {
                     $sql = "select idgroupuser, user_id FROM " . $cfg["tab"]["groupmembers"] . " WHERE\n            \t\t\t\t\t\tgroup_id = '" . Contenido_Security::escapeDB($usersequence->get("iduser"), $db) . "'";
                     $db->query($sql);
                     while ($db->next_record()) {
                         $user->loadUserByUserID($db->f("user_id"));
                         //modified : 2008-06-25 - use php mailer class instead of mail()
                         $oMail->AddAddress($user->getField("email"), "");
                         $oMail->Subject = stripslashes(i18n('Workflow notification', "workflow"));
                         $oMail->Body = $filledMail;
                         $oMail->Send();
                     }
                 } else {
                     $user->loadUserByUserID($usersequence->get("iduser"));
                     //modified : 2008-06-25 - use php mailer class instead of mail()
                     $oMail->AddAddress($user->getField("email"), "");
                     $oMail->Subject = stripslashes(i18n('Workflow notification', "workflow"));
                     $oMail->Body = $filledMail;
                     $oMail->Send();
                 }
             } else {
                 $email = "Hello %s,\n\n" . "you are assigned as the escalator for the Article %s.\n\n" . "More informations:\n" . "Article: %s\n" . "Category: %s\n" . "Editor: %s\n" . "Author: %s\n" . "Editable from: %s\n" . "Editable to: %s\n";
                 $filledMail = sprintf($email, $curEditor, $title, $title, $catname, $curEditor, $author, date("Y-m-d H:i:s", $starttime), date("Y-m-d H:i:s", $maxtime));
                 $user = new User();
                 if (isGroup($usersequence->get("iduser"))) {
                     $sql = "select idgroupuser, user_id FROM " . $cfg["tab"]["groupmembers"] . " WHERE\n            \t\t\t\t\t\tgroup_id = '" . Contenido_Security::escapeDB($usersequence->get("iduser"), $db) . "'";
                     $db->query($sql);
                     while ($db->next_record()) {
                         $user->loadUserByUserID($db->f("user_id"));
                         echo "mail to " . $user->getField("email") . "<br>";
                         //modified : 2008-06-25 - use php mailer class instead of mail()
                         $oMail->AddAddress($user->getField("email"), "");
                         $oMail->Subject = stripslashes(i18n('Workflow escalation', "workflow"));
                         $oMail->Body = $filledMail;
                         $oMail->Send();
                     }
                 } else {
                     $user->loadUserByUserID($usersequence->get("iduser"));
                     echo "mail to " . $user->getField("email") . "<br>";
                     //modified : 2008-06-25 - use php mailer class instead of mail()
                     $oMail->AddAddress($user->getField("email"), "");
                     $oMail->Subject = stripslashes(i18n('Workflow escalation', "workflow"));
                     $oMail->Body = $filledMail;
                     $oMail->Send();
                 }
             }
         }
     }
     return parent::store();
 }
 public function store()
 {
     global $auth;
     $this->set("lastmodified", date("Y-m-d H:i:s"), false);
     $this->set("modifiedby", $auth->auth["uid"]);
     parent::store();
     // Update name, email and newsletter type for recipients in pending newsletter jobs
     $sName = $this->get("name");
     $sEmail = $this->get("email");
     if ($sName == "") {
         $sName = $sEmail;
     }
     $iNewsType = $this->get("news_type");
     $oLogs = new cNewsletterLogCollection();
     $oLogs->setWhere("idnewsrcp", $this->get($this->primaryKey));
     $oLogs->setWhere("status", "pending");
     $oLogs->query();
     while ($oLog = $oLogs->next()) {
         $oLog->set("rcpname", $sName);
         $oLog->set("rcpemail", $sEmail);
         $oLog->set("rcpnewstype", $iNewsType);
         $oLog->store();
     }
 }