コード例 #1
0
ファイル: Stature.php プロジェクト: abdulnizam/zend-freniz
 public function votestature($statureid)
 {
     if (isset($this->authIdentity)) {
         $sql = $this->_db->select()->from('stature', array('userid', 'notifyusers', 'vote', 'dontnotify'))->joinLeft('freniz', 'stature.userid=freniz.userid', array('username', 'propic'))->where('statureid=?', $statureid);
         $result = $this->_db->fetchRow($sql);
         if (!empty($result)) {
             $vote = unserialize($result['vote']);
             array_push($vote, $this->authIdentity->userid);
             $vote = array_unique($vote);
             $update_data = array('vote' => serialize($vote));
             $this->update($update_data, "statureid='{$statureid}'");
             $activity = array('userid' => $this->authIdentity->userid, 'ruserid' => $result['userid'], 'contentid' => $statureid, 'title' => 'voted on', 'contenttype' => 'stature', 'contenturl' => 'stature.php?statureid=' . $statureid, 'date' => new Zend_Db_Expr('now()'), 'alternate_contentid' => 'stature_' . $statureid);
             $activityModel = new Application_Model_Activity($this->_db);
             $activityModel->insert($activity);
             $notifyusers = unserialize($result['notifyusers']);
             $vote1 = array_diff($vote, array($this->authIdentity->userid));
             $dontnotify = unserialize($result['dontnotify']);
             $notifyusers = array_unique(array_diff(array_merge($notifyusers, array($result['userid']), $vote1), $dontnotify, array($this->authIdentity->userid)));
             if (!empty($notifyusers)) {
                 $query = 'insert into notifications(userid,contenturl,notification,userpic) values ';
                 $userpic = $this->authIdentity->propic;
                 foreach ($notifyusers as $user) {
                     if (sizeof($vote1) > 1) {
                         $notificationtext = "<a href='" . $this->authIdentity->userid . "'>" . $this->authIdentity->username . "</a> and " . (sizeof($vote1) - 1) . " other voted on";
                     } else {
                         $notificationtext = "<a href='" . $this->authIdentity->userid . "'>" . $this->authIdentity->username . "</a>  voted on";
                     }
                     if ($user == $result['userid']) {
                         $notificationtext .= " your stature";
                     } else {
                         $notificationtext .= " <a href='" . $result['userid'] . "'>" . $result['username'] . "</a>'s stature";
                     }
                     $query .= ' (' . $this->_db->quote(array($user, 'stature/' . $statureid, $notificationtext, $userpic)) . '),';
                 }
                 $query = substr($query, 0, -1);
                 $query .= ' on duplicate key update notification=' . $this->_db->quote($notificationtext) . ', read1=0, time=now()';
                 $this->_db->query($query);
             }
         }
     }
 }
コード例 #2
0
ファイル: Blog.php プロジェクト: abdulnizam/zend-freniz
 public function voteBlog($blogid)
 {
     if (isset($this->authIdentity)) {
         $result = $this->find($blogid)->toArray();
         $result = $result[0];
         $vote = unserialize($result['vote']);
         array_push($vote, $this->authIdentity->userid);
         $vote = array_unique($vote);
         $update_data = array('vote' => serialize($vote));
         $this->update($update_data, "blogid='{$blogid}'");
         $activity = array('userid' => $this->authIdentity->userid, 'ruserid' => $result['userid'], 'contentid' => $blogid, 'title' => 'voted on', 'contenttype' => 'blog', 'contenturl' => 'blog.php?blogid=' . $blogid, 'date' => new Zend_Db_Expr('now()'), 'alternate_contentid' => 'blog_' . $blogid);
         $activityModel = new Application_Model_Activity($this->_db);
         $activityModel->insert($activity);
         return true;
     }
 }
コード例 #3
0
ファイル: Admiration.php プロジェクト: abdulnizam/zend-freniz
 public function voteadmire($testyid)
 {
     if (isset($this->authIdentity)) {
         $sql = $this->_db->select()->from('testimonial', array('suserid', 'ruserid', 'vote', 'dontnotify'))->joinLeft('freniz', 'testimonial.ruserid=freniz.userid', array('rusername' => 'username'))->where('testyid=?', $testyid);
         $result = $this->_db->fetchRow($sql);
         if (!empty($result)) {
             //$result=$result[0];
             $vote = unserialize($result['vote']);
             if (!in_array($this->authIdentity->userid, $vote)) {
                 array_push($vote, $this->authIdentity->userid);
                 $vote = array_unique($vote);
                 $update_data = array('vote' => serialize($vote));
                 $this->update($update_data, "testyid='{$testyid}'");
                 $activity = array('userid' => $this->authIdentity->userid, 'ruserid' => $result['ruserid'], 'contentid' => $testyid, 'title' => 'voted on', 'contenttype' => 'admire', 'contenturl' => 'admire.php?admireid=' . $testyid, 'date' => new Zend_Db_Expr('now()'), 'alternate_contentid' => 'admire_' . $testyid);
                 $activityModel = new Application_Model_Activity($this->_db);
                 $activityModel->insert($activity);
                 $dontnotify = unserialize($result['dontnotify']);
                 $votes1 = array_diff($vote, array($this->authIdentity->userid));
                 $notifyusers = array_diff(array_merge($votes1, array($result['suserid'], $result['ruserid'])), $dontnotify, array($this->authIdentity->userid));
                 $query = 'insert into notifications(userid,contenturl,notification,userpic) values ';
                 $userpic = $this->authIdentity->propic;
                 if (!empty($notifyusers)) {
                     foreach ($notifyusers as $user) {
                         if (sizeof($votes1) > 1) {
                             $notificationtext = "<a href='" . $this->authIdentity->userid . "'>" . $this->authIdentity->username . "</a> and " . (sizeof($votes1) - 1) . " other voted on";
                         } else {
                             $notificationtext = "<a href='" . $this->authIdentity->userid . "'>" . $this->authIdentity->username . "</a>  voted on";
                         }
                         if ($user == $result['ruserid']) {
                             $notificationtext .= " your admire";
                         } else {
                             $notificationtext .= " <a href='" . $result['ruserid'] . "'>" . $result['rusername'] . "</a>'s admire";
                         }
                         $query .= ' (' . $this->_db->quote(array($user, 'admire/' . $testyid, $notificationtext, $userpic)) . '),';
                     }
                     $query = substr($query, 0, -1);
                     $query .= ' on duplicate key update notification=' . $this->_db->quote($notificationtext) . ', read1=0,time=now()';
                     $this->_db->query($query);
                 }
                 /*
                 
                 				if(!empty($notifyusers1)){
                 
                 					$select_notifyusers=$this->_db->select()->from('notification')->where('userid in(?)',$notifyusers1);
                 
                 					$result_notifyusers=$this->_db->fetchAssoc($select_notifyusers);
                 
                 					$update_notification=array();
                 
                 					foreach($result_notifyusers as $user => $notifications)
                 
                 					{
                 
                 						$notifications=unserialize($notifications['notifications']);
                 
                 						$notifications["admire.php?admireid=".$testyid]=array("notification"=>  htmlspecialchars($notificationtext,ENT_QUOTES),"read"=>"0","time"=>  time());
                 
                 						$update_notification[$user]=$notifications;
                 
                 						//mysql_query("update notification set notifications='".mysql_real_escape_string(serialize($notifications))."' where userid='".$user."'");
                 
                 					}
                 
                 					$notification_case=' case userid ';
                 
                 					foreach($update_notification as $user=>$notification){
                 
                 						$notification_case.=" when '$user' then '".mysql_real_escape_string(serialize($notification))."'";
                 
                 					}
                 
                 					$notification_case.=' end';
                 
                 						
                 
                 					$this->_db->update('notification',array('notifications'=>new Zend_Db_Expr($notification_case)),array(' userid in (?)'=>array_keys($update_notification)));
                 
                 				}*/
             }
         }
     }
 }
コード例 #4
0
ファイル: Images.php プロジェクト: abdulnizam/zend-freniz
 public function voteimage($imageid)
 {
     if (isset($this->authIdentity)) {
         $sql = $this->_db->select()->from('image', array('imageid', 'albumid', 'notifyusers', 'pinnedpeople', 'dontnotify', 'userid', 'vote'))->joinLeft('album', 'album.albumid=image.albumid', 'userid as ruserid')->joinLeft('freniz', 'freniz.userid=album.userid', 'username as rusername')->where('imageid=?', $imageid);
         $result = $this->_db->fetchRow($sql);
         if (!empty($result)) {
             $vote = unserialize($result['vote']);
             if (!in_array($this->authIdentity->userid, $vote)) {
                 array_push($vote, $this->authIdentity->userid);
                 $vote = array_unique($vote);
                 $update_data = array('vote' => serialize($vote));
                 $this->update($update_data, "imageid='{$imageid}'");
                 $activity = array('userid' => $this->authIdentity->userid, 'ruserid' => $result['ruserid'], 'contentid' => $imageid, 'title' => 'voted on', 'contenttype' => 'image', 'contenturl' => 'image.php?imageid=' . $imageid, 'date' => new Zend_Db_Expr('now()'), 'alternate_contentid' => 'image_' . $imageid);
                 $activityModel = new Application_Model_Activity($this->_db);
                 $activityModel->insert($activity);
                 $notifyusers = unserialize($result['notifyusers']);
                 $pinnedpeople = unserialize($result['pinnedpeople']);
                 if (!empty($notifyusers)) {
                     $sql = $this->_db->select()->from('freniz', 'userid')->joinLeft('pinreq', 'pinreq.userid=freniz.userid and pinreq.imageid=' . $this->_db->quote($imageid) . ' and pinme.userid in (' . $this->_db->quote($pinnedpeople) . ')', '')->where('pinreq.userid is NULL and freniz.userid in (?)', $pinnedpeople);
                     $result1 = $this->_db->fetchAssoc($sql);
                     if (!empty($notifyusers)) {
                         $notifyusers = array_merge($notifyusers, array_keys($result1));
                     }
                 }
                 $vote1 = array_diff($vote, array($this->authIdentity->userid));
                 $dontnotify = unserialize($result['dontnotify']);
                 $notifyusers = array_unique(array_diff(array_merge($notifyusers, array($result['userid'], $result['ruserid']), $vote1), $dontnotify, array($this->authIdentity->userid)));
                 if (!empty($notifyusers)) {
                     $query = 'insert into notifications(userid,contenturl,notification,userpic) values ';
                     $userpic = $this->authIdentity->propic;
                     foreach ($notifyusers as $user) {
                         if (sizeof($vote1) > 1) {
                             $notificationtext = "<a href='" . $this->authIdentity->userid . "'>" . $this->authIdentity->username . "</a> and " . (sizeof($vote1) - 1) . " other voted on";
                         } else {
                             $notificationtext = "<a href='" . $this->authIdentity->userid . "'>" . $this->authIdentity->username . "</a>  voted on";
                         }
                         if ($user == $result['ruserid']) {
                             $notificationtext .= " your image";
                         } else {
                             $notificationtext .= " <a href='" . $result['userid'] . "'>" . $result['username'] . "</a>'s image";
                         }
                         $query .= ' (' . $this->_db->quote(array($user, 'image/' . $imageid, $notificationtext, $userpic)) . '),';
                     }
                     $query = substr($query, 0, -1);
                     $query .= ' on duplicate key update notification=' . $this->_db->quote($notificationtext) . ', read1=0, time=now()';
                     $this->_db->query($query);
                 }
             }
         }
     }
 }
コード例 #5
0
ファイル: UserInfo.php プロジェクト: abdulnizam/zend-freniz
 public function userVote($userid)
 {
     if (isset($this->authIdentity)) {
         $sql = $this->_db->select()->from('friends_vote')->where('userid=?', $userid);
         $result = $this->_db->fetchRow($sql);
         $votes = unserialize($result['vote']);
         if (!in_array($this->authIdentity->userid, $votes)) {
             array_push($votes, $this->authIdentity->userid);
             array_push($this->authIdentity->voted, $userid);
             $this->_db->update('friends_vote', array('vote' => serialize($votes)), array('userid=?' => $userid));
             $suserid = $this->authIdentity->userid;
             $svoted = $this->authIdentity->voted;
             $this->_db->update('friends_vote', array('voted' => serialize($svoted)), array('userid=?' => $suserid));
             $activityModel = new Application_Model_Activity($this->_db);
             $suserid = $this->authIdentity->userid;
             $activity_data = array('userid' => $suserid, 'ruserid' => $userid, 'contentid' => $userid, 'title' => 'voted on', 'contenttype' => 'user', 'contenturl' => 'profile.php?userid=' . $userid, 'date' => new Zend_Db_Expr('NOW()'), 'alternate_contentid' => 'user_' . $userid);
             $activityModel->insert($activity_data);
             $notifyusers = unserialize($result['notifyusers']);
             $vote1 = array_diff($vote, array($this->authIdentity->userid));
             $dontnotify = unserialize($result['dontnotify']);
             $notifyusers = array_unique(array_diff(array_merge($notifyusers, array($result['suserid'], $result['ruserid']), $vote1), $dontnotify, array($this->authIdentity->userid)));
             if (!empty($notifyusers)) {
                 $query = 'insert into notifications(userid,contenturl,notification,userpic) values ';
                 $userpic = $this->authIdentity->propic;
                 foreach ($notifyusers as $user) {
                     if (sizeof($vote1) > 1) {
                         $notificationtext = "<a href='" . $this->authIdentity->userid . "'>" . $this->authIdentity->username . "</a> and " . (sizeof($vote1) - 1) . " other voted on";
                     } else {
                         $notificationtext = "<a href='" . $this->authIdentity->userid . "'>" . $this->authIdentity->username . "</a>  voted on";
                     }
                     if ($user == $result['ruserid']) {
                         $notificationtext .= " your profile";
                     } else {
                         $notificationtext .= " <a href='" . $result['userid'] . "'>" . $result['username'] . "</a>'s post";
                     }
                     $query .= ' (' . $this->_db->quote(array($user, 'scribbles/' . $postid, $notificationtext, $userpic)) . '),';
                 }
                 $query = substr($query, 0, -1);
                 $query .= ' on duplicate key update notification=' . $this->_db->quote($notificationtext) . ', read1=0, time=now()';
                 $this->_db->query($query);
             }
         }
     }
 }