public function sendExpiryEmail() { $config = OW::getConfig(); $subject = OW::getLanguage()->text('sponsors', 'reminder_subject'); $content = OW::getLanguage()->text('sponsors', 'reminder_content'); $sitemail = $config->getValue('base', 'site_email'); $sitename = $config->getValue('base', 'site_name'); $mails = array(); $example = new OW_Example(); $example->andFieldEqual('status', 1); $example->andFieldGreaterThan('price', 0); $sponsors = $this->dao->findListByExample($example); foreach ($sponsors as $sponsor) { $cutoffDay = $sponsor->validity - (int) OW::getConfig()->getValue('sponsors', 'cutoffDay'); if ((time() - $sponsor->timestamp) / 86400 > $cutoffDay && $cutoffDay > 0) { $mail = OW::getMailer()->createMail(); $mail->addRecipientEmail($sponsor->email); $mail->setSender($sitemail, $sitename); $mail->setSubject($subject); $mail->setHtmlContent($content); $textContent = strip_tags(preg_replace("/\\<br\\s*[\\/]?\\s*\\>/", "\n", $content)); $mail->setTextContent($textContent); $mails[] = $mail; } } if (count($mails) > 0) { OW::getMailer()->addListToQueue($mails); } }
/** * Finds action list by type * * @param string $type */ public function findList($type) { $example = new OW_Example(); if ($type == 'earn') { $example->andFieldGreaterThan('amount', 0); } else { if ($type == 'lose') { $example->andFieldLessThan('amount', 0); } else { if ($type == 'unset') { $example->andFieldEqual('amount', 0); } } } $example->andFieldEqual('isHidden', 0); $example->andFieldEqual('active', 1); return $this->findListByExample($example); }
/** * don't call this function * This is a temporary method used for mailbox plugin update. * * @param int $messageId * @param int $limit * @return MAILBOX_BOL_Message */ public function findNotUpdatedMessages($messageId, $limit = 100) { $example = new OW_Example(); $example->andFieldGreaterThan('id', (int) $messageId); $example->setOrder(" id "); $example->setLimitClause(0, $limit); return $this->findListByExample($example); }
public function getPreviousPhoto($albumId, $id) { if (!$albumId || !$id) { return false; } $example = new OW_Example(); $example->andFieldEqual('albumId', $albumId); $example->andFieldEqual('status', 'approved'); $example->andFieldGreaterThan('id', $id); $example->setOrder('`id` ASC'); $example->setLimitClause(0, 1); return $this->findObjectByExample($example); }
/** * @return array */ public function findItemsWithInvalidLicense() { $example = new OW_Example(); $example->andFieldGreaterThan(self::LICENSE_CHECK_STAMP, 0); return $this->findListByExample($example); }
/** * Deletes reset password expired entries */ public function deleteExpiredEntities() { $example = new OW_Example(); $example->andFieldGreaterThan('expirationTimeStamp', time()); $this->deleteByExample($example); }
public function findPreviousSection($order) { if ($order === null) { return null; } $example = new OW_Example(); $example->andFieldGreaterThan('sortOrder', (int) $order); return $this->findObjectByExample($example); }
public function findUserCretedEventsCount($userId) { $example = new OW_Example(); $example->andFieldEqual(self::USER_ID, $userId); $example->andFieldGreaterThan(self::START_TIME_STAMP, time()); return $this->countByExample($example); }
public function findNewInvitationList($userId, $afterStamp = null) { $example = new OW_Example(); $example->andFieldEqual('userId', $userId); $example->andFieldEqual('viewed', false); if ($afterStamp) { $example->andFieldGreaterThan('timeStamp', $afterStamp); } $example->setOrder('timeStamp DESC'); return $this->findListByExample($example); }
public function deleteExpiredEntities() { $example = new OW_Example(); $example->andFieldGreaterThan(self::EXPIRATION_TS, time()); $this->deleteByExample($example); }
public static function processScheduler($scheduler, $user_aid = null, $limit = 10, $sendNotification = false, $sendActivity = true) { //register_shutdown_function(array('Ynmediaimporter','handleShutdown'), $scheduler -> id); //ini_set('max_execution_time',1); $movedCount = 0; $movedArray = array(); $photos = array(); $schedulerId = $scheduler->id; $userId = $scheduler->user_id; $user = BOL_UserService::getInstance()->findUserById($userId); $album = null; $example = new OW_Example(); $example->andFieldEqual('scheduler_id', $schedulerId); $example->andFieldLessThan('status', '3'); $example->andFieldGreaterThan('status', '0'); $example->setLimitClause(0, $limit); if ($user_aid) { $example->andFieldEqual('user_aid', intval($user_aid)); } $nodeList = YNMEDIAIMPORTER_BOL_NodeDao::getInstance()->findListByExample($example); $order = 0; foreach ($nodeList as $node) { if ('photo' == $node->media && $node->user_aid > 0) { $album = PHOTO_BOL_PhotoAlbumDao::getInstance()->findById($node->user_aid); if (!is_object($album)) { continue; } //download file $dir = Ynmediaimporter::getValidDir(); $file = $dir . $node->getUUID(); $privacy = OW::getEventManager()->call('plugin.privacy.get_privacy', array('ownerId' => $album->userId, 'action' => 'photo_view_album')); $photo = new PHOTO_BOL_Photo(); $photo->description = ''; $photo->albumId = $album->id; $photo->addDatetime = time(); $photo->status = 'approved'; $photo->hasFullsize = '1'; $photo->privacy = mb_strlen($privacy) ? $privacy : 'everybody'; $source = self::saveImageFromUrl($node->getDownloadFilename(), $file); $photo = self::__savePhoto($photo, $source, $userId); if ($photo) { $photos[] = $photo; $movedArray[] = array('addTimestamp' => time(), 'photoId' => $photo->id); $movedCount++; } $node->status = 3; YNMEDIAIMPORTER_BOL_NodeDao::getInstance()->save($node); } else { if (in_array($node->media, array('album', 'photoset', 'gallery')) && 0 == $node->user_aid) { // create new albums for this roles $album = self::createPhotoAlbums($scheduler, $node); // setup album and node. // update all sub node of current scheduler to this albums. $example = new OW_Example(); $example->andFieldEqual('scheduler_id', $schedulerId); $example->andFieldEqual('aid', $node->aid); $nodeTemp = YNMEDIAIMPORTER_BOL_NodeDao::getInstance()->findObjectByExample($example); $nodeTemp->user_aid = $album->id; $nodeTemp->status = '1'; YNMEDIAIMPORTER_BOL_NodeDao::getInstance()->save($nodeTemp); $node->user_aid = $album->id; $node->status = 1; YNMEDIAIMPORTER_BOL_NodeDao::getInstance()->save($node); self::processScheduler($scheduler, $album->id, 10, 0, 0); break; // force process this album to escape no value style. } } } $example = new OW_Example(); $example->andFieldEqual('scheduler_id', $schedulerId); $example->andFieldEqual('media', 'photo'); $example->andFieldLessThan('status', '3'); $remain = intval(YNMEDIAIMPORTER_BOL_NodeDao::getInstance()->countByExample($example)); // all scheduler is completed. send notification to users if (is_object($album) && $remain == 0) { // Send notification if ($sendNotification) { $actor = array('username' => BOL_UserService::getInstance()->getUserName($userId), 'name' => BOL_UserService::getInstance()->getDisplayName($userId), 'url' => BOL_UserService::getInstance()->getUserUrl($userId)); $avatars = BOL_AvatarService::getInstance()->getDataForUserAvatars(array($userId)); $event = new OW_Event('notifications.add', array('pluginKey' => 'ynmediaimporter', 'entityType' => 'ynmediaimporter_album', 'entityId' => (int) $album->id, 'action' => 'ynmediaimporter_album-added', 'userId' => $album->userId, 'time' => time()), array('avatar' => $avatars[$userId], 'string' => array('key' => 'ynmediaimporter+added_album_notification_string', 'vars' => array('actor' => $actor['name'], 'actorUrl' => $actor['url'], 'title' => $album->name, 'url' => OW::getRouter()->urlForRoute('photo_user_album', array('user' => $actor['username'], 'album' => $album->id)))), 'content' => $album->name, 'url' => OW::getRouter()->urlForRoute('photo_user_album', array('user' => $actor['username'], 'album' => $album->id)))); OW::getEventManager()->trigger($event); } if ($sendActivity) { self::__sendActivity($album, $photos, $movedArray, $movedCount); } } $scheduler->status = $remain == 0 ? 3 : 1; $scheduler->last_run = time(); YNMEDIAIMPORTER_BOL_SchedulerDao::getInstance()->save($scheduler); // and of process rec count all $tableName = OW_DB_PREFIX . 'ynmediaimporter_nodes'; $sql = "SELECT\n\t\t\t\t album.id,\n\t\t\t\t (SELECT\n\t\t\t\t COUNT( * )\n\t\t\t\t FROM {$tableName} AS photo\n\t\t\t\t WHERE photo.media = 'photo'\n\t\t\t\t AND photo.aid = album.id\n\t\t\t\t AND photo.status = 1) AS remaining\n\t\t\t\tFROM `{$tableName}` album\n\t\t\t\tWHERE album.media <> 'photo'\n\t\t\t\t AND album.status = 1\n\t\t\t\tGROUP BY album.id\n\t\t\t\tHAVING remaining = 0"; $completedList = OW::getDbo()->queryForColumnList($sql); if ($completedList) { $sql = "UPDATE `{$tableName}` SET `status` = '3' where `id` IN (" . implode(',', $completedList) . ")"; OW::getDbo()->query($sql); } return array('remain' => $remain, 'scheduler_id' => $schedulerId); }