function getCategoriesByParent($cat_pid = 0, $start = 0, $perPage = 0, $order = 'ASC') { $criteria = new criteriaCompo(new criteria('cat_pid', $cat_pid)); $criteria->setSort('cat_title'); $criteria->setOrder($order); if ($start > 0) { $criteria->setStart($start); } if ($perPage > 0) { $criteria->setLimit($perPage); } $result =& $this->handler->getObjects($criteria); return $result; }
$xoopsOption['template_main'] = 'yogurt_index.html'; include_once '../../header.php'; include_once 'class/yogurt_friendpetition.php'; include_once 'class/yogurt_friendship.php'; /** * Factory of petitions created */ $friendpetition_factory = new Xoopsyogurt_friendpetitionHandler($xoopsDB); $friendship_factory = new Xoopsyogurt_friendshipHandler($xoopsDB); $petition_id = intval($_POST['petition_id']); $friendship_level = intval($_POST['level']); $uid = intval($xoopsUser->getVar('uid')); if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header($_SERVER['HTTP_REFERER'], 3, _MD_YOGURT_TOKENEXPIRED); } $criteria = new criteriaCompo(new criteria('friendpet_id', $petition_id)); $criteria->add(new criteria('petioned_uid', $uid)); if ($friendpetition_factory->getCount($criteria) > 0) { if ($friendship_level > 0 && ($petition = $friendpetition_factory->getObjects($criteria))) { $friend1_uid = $petition[0]->getVar('petitioner_uid'); $friend2_uid = $petition[0]->getVar('petioned_uid'); $newfriendship1 = $friendship_factory->create(true); $newfriendship1->setVar('level', 3); $newfriendship1->setVar('friend1_uid', $friend1_uid); $newfriendship1->setVar('friend2_uid', $friend2_uid); $newfriendship2 = $friendship_factory->create(true); $newfriendship2->setVar('level', $friendship_level); $newfriendship2->setVar('friend1_uid', $friend2_uid); $newfriendship2->setVar('friend2_uid', $friend1_uid); $friendpetition_factory->deleteAll($criteria); $friendship_factory->insert($newfriendship1);
$nb_petitions = sizeof($newpetition); $petitioner_handler =& xoops_gethandler('member'); $petitioner =& $petitioner_handler->getUser($newpetition[0]->getVar('petitioner_uid')); $petitioner_uid = $petitioner->getVar('uid'); $petitioner_uname = $petitioner->getVar('uname'); $petitioner_avatar = $petitioner->getVar('user_avatar'); $petition_id = $newpetition[0]->getVar('friendpet_id'); $petition = 1; } } /** * Criteria for mainvideo */ $criteria_uidvideo = new criteria('uid_owner', $controler->uidOwner); $criteria_mainvideo = new criteria('main_video', "1"); $criteria_video = new criteriaCompo($criteria_mainvideo); $criteria_video->add($criteria_uidvideo); if ($nbSections['nbVideos'] > 0 && ($videos = $controler->videos_factory->getObjects($criteria_video))) { $mainvideocode = $videos[0]->getVar('youtube_code'); $mainvideodesc = $videos[0]->getVar('video_desc'); } /** * Friends */ $criteria_friends = new criteria('friend1_uid', $controler->uidOwner); $friends = $controler->friendships_factory->getFriends(9, $criteria_friends); $controler->visitors_factory->purgeVisits(); $evaluation = $controler->friendships_factory->getMoyennes($controler->uidOwner); /** * Tribes */
* Getting the uid of the user which user want to ask to be friend */ $petitioned_uid = $_POST['petitioned_uid']; /** * Verify Token */ if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header($_SERVER['HTTP_REFERER'], 3, _MD_YOGURT_TOKENEXPIRED); } //Verify if the user has already asked for friendship or if the user he s asking to be a friend has already asked him $criteria = new criteriaCompo(new criteria('petioned_uid', $petitioned_uid)); $criteria->add(new criteria('petitioner_uid', $xoopsUser->getVar('uid'))); if ($friendpetition_factory->getCount($criteria) > 0) { redirect_header(XOOPS_URL . "/modules/yogurt/index.php?uid=" . $_POST['petitioned_uid'], 3, _MD_YOGURT_ALREADY_PETITIONED); } else { $criteria2 = new criteriaCompo(new criteria('petitioner_uid', $petitioned_uid)); $criteria2->add(new criteria('petioned_uid', $xoopsUser->getVar('uid'))); if ($friendpetition_factory->getCount($criteria2) > 0) { redirect_header(XOOPS_URL . "/modules/yogurt/index.php?uid=" . $_POST['petitioned_uid'], 3, _MD_YOGURT_ALREADY_PETITIONED); } } /** * create the petition in database */ $newpetition = $friendpetition_factory->create(true); $newpetition->setVar('petitioner_uid', $xoopsUser->getVar('uid')); $newpetition->setVar('petioned_uid', $_POST['petitioned_uid']); if ($friendpetition_factory->insert($newpetition)) { $extra_tags['X_OWNER_NAME'] = $xoopsUser->getVar('uname'); $extra_tags['X_OWNER_UID'] = $xoopsUser->getVar('uid'); $notification_handler =& xoops_gethandler('notification');
function getFirstChildren($cat_id) { $mytree =& $this->getTreeInstance(); //new XoopsTree($this->db->prefix('_category'), 'cat_id', 'cat_pid'); $subarr = $mytree->getFirstChildId($cat_id, 'cat_id'); $criteria = new criteriaCompo(new criteria('cat_id', -1)); foreach ($subarr as $sub) { $criteria->add(new criteria('cat_id', $sub), 'OR'); } $subcat =& $this->getObjects($criteria); return $subcat; }
function renderFormSubmit($friend) { global $xoopsUser; /** * criteria fetch friendship to be edited */ $criteria_friend1 = new criteria('friend1_uid', $xoopsUser->getVar('uid')); $criteria_friend2 = new criteria('friend2_uid', $friend->getVar('uid')); $criteria_friendship = new criteriaCompo($criteria_friend1); $criteria_friendship->add($criteria_friend2); $friendships = $this->getObjects($criteria_friendship); $friendship = $friendships[0]; $form = new XoopsThemeForm(_MD_YOGURT_EDITFRIENDSHIP, "form_editfriendship", "editfriendship.php", "post", true); //$field_friend_avatar = new XoopsFormLabel(_MD_YOGURT_PHOTO, "<img src=../../uploads/".$friend->getVar('user_avatar')." />"); if ($friend->getVar('user_avatar') == "blank.gif") { $field_friend_avatar = new XoopsFormLabel(_MD_YOGURT_PHOTO, "<img src=images/noavatar.gif />"); } else { $field_friend_avatar = new XoopsFormLabel(_MD_YOGURT_PHOTO, "<img src=../../uploads/" . $friend->getVar('user_avatar') . " />"); } $field_friend_name = new XoopsFormLabel(_MD_YOGURT_FRIENDNAME, $friend->getVar('uname')); $field_friend_fan = new XoopsFormRadioYN(_MD_YOGURT_FAN, "fan", $friendship->getVar('fan'), '<img src="images/fans.gif" alt="' . _YES . '" title="' . _YES . '" />', '<img src="images/fansbw.gif" alt="' . _NO . '" title="' . _NO . '" />'); $field_friend_level = new XoopsFormRadio(_MD_YOGURT_LEVEL, "level", $friendship->getVar('level'), "<br />"); $field_friend_level->addOption("1", _MD_YOGURT_UNKNOWNACCEPTED); $field_friend_level->addOption("3", _MD_YOGURT_AQUAITANCE); $field_friend_level->addOption("5", _MD_YOGURT_FRIEND); $field_friend_level->addOption("7", _MD_YOGURT_BESTFRIEND); $field_friend_sexy = new XoopsFormRadio(_MD_YOGURT_SEXY, "hot", $friendship->getVar('hot')); $field_friend_sexy->addOption("1", '<img src="images/sexya.gif" alt="' . _MD_YOGURT_SEXYNO . '" title="' . _MD_YOGURT_SEXYNO . '" />'); $field_friend_sexy->addOption("2", '<img src="images/sexyb.gif" alt="' . _MD_YOGURT_SEXYYES . '" title="' . _MD_YOGURT_SEXYYES . '" />'); $field_friend_sexy->addOption("3", '<img src="images/sexyc.gif" alt="' . _MD_YOGURT_SEXYALOT . '" title="' . _MD_YOGURT_SEXYALOT . '" />'); $field_friend_trusty = new XoopsFormRadio(_MD_YOGURT_TRUSTY, "trust", $friendship->getVar('trust')); $field_friend_trusty->addOption("1", '<img src="images/trustya.gif" alt="' . _MD_YOGURT_TRUSTYNO . '" title="' . _MD_YOGURT_TRUSTYNO . '" />'); $field_friend_trusty->addOption("2", '<img src="images/trustyb.gif" alt="' . _MD_YOGURT_TRUSTYYES . '" title="' . _MD_YOGURT_TRUSTYYES . '" />'); $field_friend_trusty->addOption("3", '<img src="images/trustyc.gif" alt="' . _MD_YOGURT_TRUSTYALOT . '" title="' . _MD_YOGURT_TRUSTYALOT . '" />'); $field_friend_cool = new XoopsFormRadio(_MD_YOGURT_COOL, "cool", $friendship->getVar('cool')); $field_friend_cool->addOption("1", '<img src="images/coola.gif" alt="' . _MD_YOGURT_COOLNO . '" title="' . _MD_YOGURT_COOLNO . '" />'); $field_friend_cool->addOption("2", '<img src="images/coolb.gif" alt="' . _MD_YOGURT_COOLYES . '" title="' . _MD_YOGURT_COOLYES . '" />'); $field_friend_cool->addOption("3", '<img src="images/coolc.gif" alt="' . _MD_YOGURT_COOLALOT . '" title="' . _MD_YOGURT_COOLALOT . '" />'); $form->setExtra('enctype="multipart/form-data"'); $button_send = new XoopsFormButton("", "submit_button", _MD_YOGURT_UPDATEFRIEND, "submit"); $field_friend_friendid = new XoopsFormHidden("friend_uid", $friend->getVar('uid')); $field_friend_marker = new XoopsFormHidden("marker", "1"); $field_friend_friendshio_id = new XoopsFormHidden("friendship_id", $friendship->getVar('friendship_id')); $form->addElement($field_friend_friendid); $form->addElement($field_friend_friendshio_id); $form->addElement($field_friend_marker); $form->addElement($field_friend_avatar); $form->addElement($field_friend_name); $form->addElement($field_friend_level); $form->addElement($field_friend_fan); $form->addElement($field_friend_sexy); $form->addElement($field_friend_trusty); $form->addElement($field_friend_cool); $form->addElement($button_send); $form->display(); //If your server is php 4.4 }
/** * Set permissions acording to user is logged or not , is owner or not etc.. * * @return void */ function getPermissions() { global $_GET, $xoopsUser; /** * @desc Check if the user uid exists if not redirect back to where he was */ if (!empty($_GET['uid'])) { $member_handler =& xoops_gethandler('member'); $user =& $member_handler->getUser(intval($_GET['uid'])); if (!is_object($user)) { redirect_header("index.php", 3, _MD_YOGURT_USERDOESNTEXIST); } } /** * If anonym and uid not set then redirect to admins profile * Else redirects to own profile */ if (empty($this->user)) { $this->isAnonym = 1; $this->isUser = 0; if (!empty($_GET['uid'])) { $this->uidOwner = intval($_GET['uid']); } else { $this->uidOwner = 1; $this->isOwner = 0; } } else { $this->isAnonym = 0; $this->isUser = 1; if (!empty($_GET['uid'])) { $this->uidOwner = intval($_GET['uid']); $this->isOwner = $this->user->getVar('uid') == intval($_GET['uid']) ? 1 : 0; } else { $this->uidOwner = $this->user->getVar('uid'); $this->isOwner = 1; } } $this->owner = new XoopsUser($this->uidOwner); $criteria_suspended = new Criteria("uid", $this->uidOwner); $this->isSuspended = $this->suspensions_factory->getCount($criteria_suspended) > 0 ? 1 : 0; if ($this->owner->getVar('name') == "") { $this->nameOwner = $this->owner->getVar('uname'); } else { $this->nameOwner = $this->owner->getVar('name'); } //isfriend? $criteria_friends = new criteria('friend1_uid', $this->uidOwner); if (!$xoopsUser) { $controler->isFriend = 0; } else { $criteria_isfriend = new criteriaCompo(new criteria('friend2_uid', $this->user->getVar('uid'))); $criteria_isfriend->add($criteria_friends); $this->isFriend = $this->friendships_factory->getCount($criteria_isfriend); } $this->privilegeLevel = 0; if ($this->isAnonym == 1) { $this->privilegeLevel = 0; } if ($this->isUser == 1) { $this->privilegeLevel = 1; } if ($this->isFriend == 1) { $this->privilegeLevel = 2; } if ($this->isOwner == 1) { $this->privilegeLevel = 3; } }
/** * get entries of categories specified in array sorted order by cat_id, created for index.php * @author hodaka <*****@*****.**> */ function getEntriesByCategoryArray($currentuid, $cid_array = array(), $user_id = 0, $start = 0, $perPage = 0, $order = 'DESC') { $criteria = new criteriaCompo(new criteria('user_id', $currentuid)); $criteria->add(new criteria('private', 'N'), 'OR'); $criteria = new criteriaCompo($criteria); $criteria->add(new Criteria('cat_id', "(" . implode(',', $cid_array) . ")", 'IN')); if ($user_id > 0) { $criteria->add(new criteria('user_id', $user_id)); } $criteria->setSort('cat_id, created'); $criteria->setOrder($order); if ($start > 0) { $criteria->setStart($start); } if ($perPage > 0) { $criteria->setLimit($perPage); } $result =& $this->handler->getObjects($criteria); return $result; }
*/ $nbSections = $controler->getNumbersSections(); /** * This variable define the beggining of the navigation must b * setted here so all calls to database will take this into account */ $start = isset($_GET['start']) ? intval($_GET['start']) : 0; /** * Filter for search pictures in database */ if ($controler->isOwner == 1) { $criteria_uid = new criteria('uid_owner', $controler->uidOwner); } else { $criteria_private = new criteria('private', 0); $criteria_uid2 = new criteria('uid_owner', intval($controler->uidOwner)); $criteria_uid = new criteriaCompo($criteria_uid2); $criteria_uid->add($criteria_private); } $criteria_uid->setLimit($xoopsModuleConfig['picturesperpage']); $criteria_uid->setStart($start); if ($xoopsModuleConfig['images_order'] == 1) { $criteria_uid->setOrder('DESC'); $criteria_uid->setSort('cod_img'); } /** * Fetch pictures from factory */ $pictures_object_array = $controler->album_factory->getObjects($criteria_uid); $criteria_uid->setLimit(''); $criteria_uid->setStart(0); /**
$uid_voter = intval($xoopsUser->getVar('uid')); if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header($_SERVER['HTTP_REFERER'], 3, _MD_YOGURT_TOKENEXPIRED); } /** * Verify if user is trying to vote for himself */ if ($uid_voter == $uid_voted) { redirect_header($_SERVER['HTTP_REFERER'], 3, _MD_YOGURT_CANTVOTEOWN); } /** * Verify that this user hasn't voted or added this user yet */ $criteria_uidvoter = new criteria('uid_voter', $uid_voter); $criteria_uidvoted = new criteria('uid_voted', $uid_voted); $criteria = new criteriaCompo($criteria_uidvoter); $criteria->add($criteria_uidvoted); if ($ishot_factory->getCount($criteria) == 0) { $vote = $ishot_factory->create(true); $vote->setVar('uid_voted', $uid_voted); $vote->setVar('uid_voter', $uid_voter); if ($ishot == 1) { $vote->setVar('ishot', 1); } else { $vote->setVar('ishot', 0); } $ishot_factory->insert($vote); redirect_header($_SERVER['HTTP_REFERER'], 3, _MD_YOGURT_VOTED); } else { redirect_header($_SERVER['HTTP_REFERER'], 3, _MD_YOGURT_ALREADYVOTED); }