protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $url = sfConfig::get('op_base_url');
     if ($arguments['mode'] == "morning") {
         $message = "おはようございます。昨日の勤怠報告が済んでいない方は報告よろしくお願いします。";
     } elseif ($arguments['mode'] == "afternoon") {
         $message = "お疲れ様です。退勤される方は勤怠報告をよろしくおねがいします。";
     } elseif ($arguments['mode'] == "evening") {
         $message = "お疲れ様です。退勤される方は勤怠報告をよろしくおねがいします。";
     } else {
         $message = "";
     }
     if ($message) {
         $message = $message . " " . $url . "/kintai";
         $activity = new ActivityData();
         $activity->setMemberId(1);
         $activity->setBody($message);
         $activity->setIsMobile(0);
         $activity->save();
         echo "Posted via Acvitity.\n";
     } else {
         echo "Posted failure. Maybe incorrect arguments.\n";
     }
 }
  protected function execute($arguments = array(), $options = array())
  {
    $databaseManager = new sfDatabaseManager($this->configuration);
    $this->conn = $databaseManager->getDatabase('doctrine')->getDoctrineConnection();

    $sql = 'SELECT id FROM member WHERE is_active != 0';
    $where = array();
    if ( $options['min'] && $options['max']  && $options['min'] <= $options['max'])
    {
        $sql .= ' AND id BETWEEN ? AND ?';
        $where = array(intval($options['min']),intval($options['max']));
    }
    $memberIds = $this->conn->fetchColumn($sql, $where);

    foreach ($memberIds as $memberid)
    {
      for ($i=0; $i<$options['number']; ++$i)
      {
        $ac = new ActivityData();
        $ac->setMemberId($memberid);
        $ac->setBody(md5($i));
        $ac->setPublicFlag(1);
        $ac->save();
        $ac->free();
        $this->logSection('posted a activity', sprintf('%s', $memberid));
      }
    }
  }
 public function updateActivity($memberId, $body, $options = array())
 {
     $object = new ActivityData();
     $object->setMemberId($memberId);
     $object->setBody($body);
     if (isset($options['public_flag'])) {
         $publicFlagKeys = array_keys($this->getPublicFlags(false));
         if (!in_array($options['public_flag'], $publicFlagKeys)) {
             throw new LogicException('Invalid public flag');
         }
         $object->setPublicFlag($options['public_flag']);
     }
     if (isset($options['in_reply_to_activity_id'])) {
         $object->setInReplyToActivityId($options['in_reply_to_activity_id']);
     }
     if (isset($options['is_pc']) && !$options['is_pc']) {
         $object->setIsPc(false);
     }
     if (isset($options['is_mobile']) && !$options['is_mobile']) {
         $object->setIsMobile(false);
     }
     if (isset($options['uri'])) {
         $object->setUri($options['uri']);
     }
     if (isset($options['source'])) {
         $object->setSource($options['source']);
         if (isset($options['source_uri'])) {
             $object->setSourceUri($options['source_uri']);
         }
     }
     $activityImages = array();
     if (isset($options['images'])) {
         if (!is_array($options['images'])) {
             $options['images'] = array($options['images']);
         }
         foreach ($options['images'] as $image) {
             $activityImage = new ActivityImage();
             if (isset($image['file_id'])) {
                 $activityImage->setFileId($image['file_id']);
             } elseif (isset($image['uri']) && isset($image['mime_type'])) {
                 $activityImage->setUri($image['uri']);
                 $activityImage->setMimeType($image['mime_type']);
             } else {
                 throw new LogicException('Invalid image data');
             }
             $activityImages[] = $activityImage;
         }
     }
     if (isset($options['foreign_table']) && isset($options['foreign_id'])) {
         $object->setForeignTable($options['foreign_table']);
         $object->setForeignId($options['foreign_id']);
     }
     $object->save();
     foreach ($activityImages as $activityImage) {
         $activityImage->setActivityData($object);
         $activityImage->save();
     }
     return $object;
 }
 public function executePost(sfWebRequest $request)
 {
     $form = new sfForm();
     $token = $form->getCSRFToken();
     if ($token = !$request->getParameter('CSRFtoken')) {
         $json = array('status' => 'error', 'message' => 'Error. Invalid CSRF token Key.');
         return $this->renderText(json_encode($json));
     }
     if (!$request->getParameter('body')) {
         $json = array('status' => 'error', 'message' => 'Error. Body is null.');
         return $this->renderText(json_encode($json));
     }
     $activity = new ActivityData();
     $activity->setMemberId($this->getUser()->getMemberId());
     $activity->setBody($request->getParameter('body'));
     $mentions = opTimelinePluginUtil::hasScreenName($request->getParameter('body'));
     if (!is_null($mentions)) {
         $activity->setTemplate('mention_member_id');
         $activity->setTemplateParam($mentions);
     }
     $inReplyToActivityId = $request->getParameter('replyId');
     if (isset($inReplyToActivityId) && is_numeric($inReplyToActivityId)) {
         $activity->setInReplyToActivityId($inReplyToActivityId);
     }
     $foreign = $request->getParameter('foreign');
     $foreignId = $request->getParameter('foreignId');
     if (isset($foreign) && isset($foreignId) && is_numeric($foreignId)) {
         $activity->setForeignTable($foreign);
         $activity->setForeignId($foreignId);
     }
     $activity->setPublicFlag(1);
     $activity->save();
     $json = array('status' => 'success', 'message' => 'UPDATE was succeed!');
     return $this->renderText(json_encode($json));
 }
 public function executePost(sfWebRequest $request)
 {
     $this->getResponse()->setContentType('application/json');
     if ($token = !$request->getParameter('body')) {
         $this->status = 'error';
         $this->message = 'Error. Body is null.';
         return sfView::SUCCESS;
     }
     $activity = new ActivityData();
     $activity->setMemberId($this->getMember()->getId());
     $activity->setBody(htmlspecialchars($request->getParameter('body'), ENT_QUOTES));
     $mentions = opTimelinePluginUtil::hasScreenName($request->getParameter('body'));
     if (!is_null($mentions)) {
         $activity->setTemplate('mention_member_id');
         $activity->setTemplateParam($mentions);
     }
     $inReplyToActivityId = $request->getParameter('replyId');
     if (isset($inReplyToActivityId) && is_numeric($inReplyToActivityId)) {
         $activity->setInReplyToActivityId($inReplyToActivityId);
     }
     $foreign = $request->getParameter('foreign');
     $foreignId = $request->getParameter('foreignId');
     if (isset($foreign) && isset($foreignId) && is_numeric($foreignId)) {
         $activity->setForeignTable($foreign);
         $activity->setForeignId($foreignId);
     }
     $activity->setPublicFlag(1);
     $activity->save();
     $this->status = 'success';
     $this->message = "Update request was suceed!";
     return sfView::SUCCESS;
 }