コード例 #1
0
ファイル: PositionObj.php プロジェクト: jbrauchler/directory
 public function pre_delete()
 {
     if (!$this->is_valid_id()) {
         return false;
     }
     $conn = Yii::app()->db;
     $query = "\n\t\t\tSELECT\t\tcid\n\t\t\tFROM\t\t{{contacts}}\n\t\t\tWHERE\t\tpositions LIKE :positions\n\t\t";
     $command = $conn->createCommand($query);
     $command->bindValue(":positions", "%" . $this->posid . "%");
     $result = $command->queryAll();
     if (!$result or empty($result)) {
         return false;
     }
     foreach ($result as $row) {
         $contact = new ContactObj($row["cid"]);
         $contact->remove_position($this->posid);
         $contact->save();
     }
     return true;
 }
コード例 #2
0
 public function action_remove_contact_tag()
 {
     $this->noGuest();
     $contact = new ContactObj($_REQUEST["cid"]);
     if (!$contact->loaded) {
         return print "Contact could not be found.";
     }
     $tags = array_flip(explode(",", $contact->tags));
     unset($tags[$_REQUEST["tag"]]);
     $contact->tags = implode(",", array_keys($tags));
     if (!$contact->save()) {
         $name = $contact->firstname . " " . $contact->lastname;
         $log = new LogObj();
         $log->type = "error";
         $log->log_message = "Attempting to update tags of contact (" . $contact->cid . ") \"{$name}\" bio.\n";
         $log->log_message .= $contact->get_error();
         if (!$log->save()) {
             die($log->get_error());
         }
         return print $log->log_message;
     }
     return print 1;
 }