Пример #1
0
 public function action_save_notes()
 {
     if (Yii::app()->user->isGuest) {
         return print "You need ot be logged in to save notes.";
     }
     $contact = new ContactObj($_REQUEST["cid"]);
     if (!$contact->loaded) {
         return print "Contact could not be found.";
     }
     $user = new UserObj(Yii::app()->user->name);
     if (!$user->loaded) {
         return print "You need to be logged in to save notes.";
     }
     $oldnotes = $contact->load_notes($user->username);
     $newnotes = $_REQUEST["notes"];
     # Save the notes
     if (!$contact->save_notes($user->username, $newnotes)) {
         $log = new LogObj();
         $log->type = "error";
         $log->log_message = "Attempting to update contact(" . $contact->cid . ") notes from \"{$oldnotes}\" to \"{$newnotes}\".\n";
         $log->log_message .= $contact->get_error();
         if (!$log->save()) {
             die($log->get_error());
         }
         return print $log->log_message;
     }
     return print 1;
 }