function getTwitterAccounts()
 {
     $object = new CRM_CiviruleTwitter_BAO_TwitterAccount();
     $object->find();
     $return = array();
     while ($object->fetch()) {
         $return[$object->id] = '@' . $object->twitter_name . ' - ' . $object->description;
     }
     return $return;
 }
 /**
  * Returns a user friendly text explaining the condition params
  * e.g. 'Older than 65'
  *
  * @return string
  * @access public
  */
 public function userFriendlyConditionParams()
 {
     $params = $this->getActionParameters();
     $account = ts('Unknown');
     $twitter_account = new CRM_CiviruleTwitter_BAO_TwitterAccount();
     $twitter_account->id = $params['twitter_account'];
     if ($twitter_account->find(true)) {
         $description = '';
         if ($twitter_account->description) {
             $description = ' "' . $twitter_account->description . '"';
         }
         $account = '@' . $twitter_account->twitter_name . ' ' . $description;
     }
     return sprintf('Tweet: "%s" %s', $params['status'], $account);
 }
 public function postProcess()
 {
     if ($this->_action & CRM_Core_Action::DELETE) {
         CRM_CiviruleTwitter_BAO_TwitterAccount::deleteWithId($this->_id);
         CRM_Core_Session::setStatus(ts('Selected twitter account has been deleted.'), '', 'success');
     } else {
         $params = array();
         // store the submitted values in an array
         $params = $this->exportValues();
         if ($this->_action & CRM_Core_Action::UPDATE) {
             $params['id'] = $this->_id;
         }
         CRM_CiviruleTwitter_BAO_TwitterAccount::add($params);
         CRM_Core_Session::setStatus(ts('Your twitter account has been saved'), '', 'success');
     }
 }
function civicrm_api3_twitter_account_get($params)
{
    $returnValues = CRM_CiviruleTwitter_BAO_TwitterAccount::getValues($params);
    return civicrm_api3_create_success($returnValues, $params, 'TwitterAccount', 'Get');
}
 /**
  * Function to delete with id
  *
  * @param int $id
  * @throws Exception when id is empty
  * @access public
  * @static
  */
 public static function deleteWithId($id)
 {
     if (empty($id)) {
         throw new Exception('id can not be empty when attempting to delete a twitter account');
     }
     CRM_Utils_Hook::pre('delete', 'TwitterAccount', $id, CRM_Core_DAO::$_nullArray);
     $rule = new CRM_CiviruleTwitter_BAO_TwitterAccount();
     $rule->id = $id;
     $rule->delete();
     CRM_Utils_Hook::post('delete', 'TwitterAccount', $id, CRM_Core_DAO::$_nullArray);
     return;
 }